I have problem with Video.js with i use it as component in vue.js. I recieve a .mpd link from a Server and i want to show the video from the link, i did like the example in documentation Video.js and Vue integration.
always the first time i call the VideoPlayer showed an Error:
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media.
When i go out to the previous page and then to the VideoPlayer again it works. ( also do not works when i refresh the page )
P.s: i use vuex to get all data from Server.
Here is my Code for Stream.vue:
<template>
<div class="container">
<h1 class="text-center">MediaPlayer for: {{ mediaName }}</h1>
<video-player :options="videoOptions" />
</div>
</template>
<script>
import { mapState, mapActions } from "vuex";
import VideoPlayer from "@/components/VideoPlayer.vue";
export default {
name: "Stream",
props: ["stream_id", "source"],
components: {
VideoPlayer
},
created() {
this.fetchStream(this.stream_id);
},
computed: {
...mapState("stream", ["stream", "mediaName"]),
videoOptions() {
return {
autoplay: false,
controls: true,
sources: [
{
src: this.stream.stream_link,
type: "application/dash+xml"
}
],
poster:"http://placehold.it/380?text=DMAX Video 2"
};
}
},
methods: {
...mapActions("stream", ["fetchStream"])
}
};
</script>
<style scoped></style>
and Here is VideoPlayer.vue:
<template>
<div>
<video ref="videoPlayer" class="video-js"></video>
</div>
</template>
<script>
import videojs from "video.js";
export default {
name: "VideoPlayer",
props: {
options: {
type: Object,
default() {
return {};
}
}
},
data() {
return {
player: null
};
},
mounted() {
this.player = videojs(
this.$refs.videoPlayer,
this.options,
function onPlayerReady() {
console.log("onPlayerReady", this);
}
);
},
beforeDestroy() {
if (this.player) {
this.player.dispose();
}
}
};
</script>