Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the expected behavior for play twice #6

Open
totty90 opened this issue Feb 4, 2015 · 2 comments
Open

What is the expected behavior for play twice #6

totty90 opened this issue Feb 4, 2015 · 2 comments
Labels

Comments

@totty90
Copy link

totty90 commented Feb 4, 2015

Let's say I have this:

var i = 0;
setInterval(function(){
    omx.play('video' + (i++));
}, 1000)

Videos are longer than 1 second. Let's say for this example that they are 5 seconds long.

The player will (A): plays right away

  • Second 0: nothing happens;
  • Second 1: omx plays video0;
  • Second 2: omx plays video1;

The player will (B): queue incoming videos

  • Second 0: nothing happens;
  • Second 1: omx plays video0;
  • Second 2: omx still plays video0 until ends;
  • Second 5: omx plays video1;

The player will (C): doesn't queue incoming videos

  • Second 0: nothing happens;
  • Second 1: omx plays video0;
  • Second 2: omx still plays video0 until ends;
  • Second 5: nothing happens

Seems that it works like in case C.

So to make it work the code should be:

var i = 0;
setInterval(function(){
    omx.stop();
    omx.play('video' + (i++));
}, 1000)

Or I have to wait for the stop event to fire before starting again?

I can't test the app, so knowing the behaviour would help me to design the app properly without seeing what happens.

@alepez
Copy link
Owner

alepez commented Feb 4, 2015

I think the expected behavior is (A). But actually it is (C). I guess it is caused by https://github.com/alessandro-pezzato/omxdirector/blob/v0.1.1/lib/main.js#L175
Because play() awakes a paused video. I will fix it asap.

@alepez alepez added the bug label Feb 4, 2015
@totty90
Copy link
Author

totty90 commented Feb 4, 2015

I use a wrapper on your omxdirector lib and in this I do like this when play is called:

  • if playing omx.stop(cb); // the cb is run when omx is stopped

The stop method is like this:

stop: function(cb){
    if(this.__simulationMode){
        cb && cb();
        return;
    }
    this.__omx.once('stop', function(){
        cb && cb();
    });
    this.__omx.stop();
},

Notice how I listen on the stop event once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants