VIDEOJS : Dynamically change src of a video
VIDEOJS : WARN: Player x is already initialised. Options will not be applied
You will be getting above warning, if you try to change src of an already initialised video element, this is what you can do to avoid the warning and change src dynamically
if (videojs.getPlayers()[`hls-video`]) {
// hls-video is the id of the video tag
delete videojs.getPlayers()[`hls-video`];
}
videojs(`#hls-video`).src({
src: link, // dynamic link
type: "application/x-mpegURL" // type
});
First you have to check, if videojs is already initialized using videojs.getPlayers(), if already initialized, you can delete it using delete videojs.getPlayers() and then you can start all over
ALTERNATE TITLES