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

How to check the play status? #41

Open
plutarcociceron opened this issue Jun 30, 2016 · 1 comment
Open

How to check the play status? #41

plutarcociceron opened this issue Jun 30, 2016 · 1 comment

Comments

@plutarcociceron
Copy link

Hi, is there a way how check if the player is paused or not?
Something like this?
$scope.$watch('vjsVideoIsPlaying', function(oldVal, newVal) {
if (oldVal) {
console.log('old: ', oldVal);
}
});

@ghost
Copy link

ghost commented Jul 1, 2016

@plutarcociceron currently the way to do what you're looking for is to get a reference to the player once it is ready. In a future update the plan is to have an angular service handle this type of logic but you to check play status for videos something like the following could work:

var videos = {};
$scope.$on('vjsVideoReady', function (e, data) {
    videos[data.id] = data.player;

    videos[data.id].on('play', function (e) {
        console.log('video is playing:' + this.id());
    });
});

This stores all videos on a page in an object and adds a listener for play.

If at some later time you wanted to see if the a video with an id of example_vid was paused you could do the following:

if (videos['example_vid'].paused()) {
    console.log('video is paused');
}

Let me know if that makes sense or if you have suggestions on making this easier to deal with.

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

No branches or pull requests

1 participant