0

I am building a player logic that loads a movie, plays it to the end, reacts to the "ended" event and sets a new source, that has to be looped until the user interacts. Then, film2 gets played and "switches into loop" as well so i'm loading another src and setting options to loop for the loop.

I just couldn't get it to work.

Here is my code:

<video id="video_1" preload="auto" width="100%" height="100%">
    <source src="video/dummy/dummy_film1.mp4" type='video/mp4'>
</video>

And here is my js:

function initialVideoFinished(){
    _myPlayer.off('ended', initialVideoFinished);
    console.log('video1 finished - video js READY');
    console.log('myPlayer id == ' + _myPlayer);
    _V_('video_1', {'loop' : 'true'});
    _myPlayer.src('video/dummy/dummy_loop1.mp4');
    _myPlayer.play();
    ni_resize();
}

I tried a lot of variations. Loop in "" or without or _myPlayer.loop = true; V(...) oder just videojs(..) but the new video src never loops.

I also tried replacing the whole tag. This works, but then I lose my reference to the player object.

How can I do this?

1 Answer 1

1

You can use loop(true):

var myPlayer = videojs("my_video_1");
function initialVideoFinished(event) {
    console.log("end");
    myPlayer.off('ended', initialVideoFinished);
    myPlayer.src("http://example.com/newsource.mp4");
    myPlayer.loop(true);
    myPlayer.play();
}
myPlayer.on('ended', initialVideoFinished);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.