Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

How to loop a popcorn.js sequence? #370

Open
anabelle opened this Issue · 2 comments

2 participants

@anabelle

I have created a simple sequence of videos using popcorn.js following the documentation: http://popcornjs.org/popcorn-docs/modules/#sequence

I need the sequence to loop after ending so I added a listener like:

function playsequence(){
    sequence.play();
}
sequence.listen( 'canplaythrough', playsequence );
sequence.listen( 'ended', playsequence );

The thing is that when the sequence ends, the last video is repeated once and then it stops.

Any idea on how could I get a loop for the entire sequence?

@ScottDowne
Owner
@anabelle

I've been looking at sequencer but I can't find good documentation.

I managed to do it using sequence like this:

clips = [
            {
                src: "/video/720_1.mp4",
                in: 0,
                out: videos_duracion
            },
            {
                src: "/video/720_2.mp4",
                in: 0,
                out: videos_duracion
            }
        ];

loop = 0;
function init(){
    if( typeof sequence != "undefined" ){
        sequence.remove();
    }
    sequence = Popcorn.sequence(
        "broadcast",
        clips
    );
    sequence.listen( 'canplaythrough', sequence.play() );
    sequence.listen( 'ended', init );
    console.log( loop );
    loop = loop+1;
}

init();

It seems to be working fine, although it sometimes stops randomly after several repetitions without throwing any error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.