npm install video.js -S
import Videojs from "video.js";
import "video.js/dist/video-js.css";
<video ref="videoPlayerRef" class="video-js"></video>
props: {
src: {
type: String,
default:
"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 ",
},
},
data() {
return {
player: null,
videoPlayerOption: {
controls: true,
poster: "",
autoplay: true,
muted: true,
preload: "auto",
fluid: true,
},
};
},
mounted() {
console.log(this.src, "this.src");
this.player = Videojs(this.$refs.videoPlayerRef, this.videoPlayerOption, () => {
this.player.src({ src: this.src, type: "application/x-mpegURL" })
this.player.play();
});
},
beforeDestroy() {
if (this.player) {
this.player.dispose();
}
}