The Web Blinders logo

Programming

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

how to change src videojs

hls.js change dynamically how to

VideoJS - unable to destroy and initialize - Stack Overflow

Destroy videojs instance

Live streaming change src dynamically videojs

Need developers ?

if so, send a message.

thewebblinders@gmail.com

More Programming from our blog

SEARCH FOR ARTICLES