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

Already on GitHub? Sign in to your account

Feature Request: isPlaying() method #181

Closed
dominic-p opened this Issue May 2, 2012 · 9 comments

Comments

Projects
None yet
7 participants
Contributor

dominic-p commented May 2, 2012

Hello, in adding some custom event handlers I'm finding it necessary to determine if the video is currently playing or not. This is possible (albeit convoluted) with the HTML5 tech, but I have no idea how to go about it with the flash tech.

It might be nice to have an abstracted isPlaying() method that simply returns true or false based on if the video is playing or not.

Owner

heff commented May 3, 2012

You can use the paused() function. myPlayer.paused() will return false if it's playing. This is how HTML5 video handles it, and with video.js it will work with HTML5 and flash.

@heff heff closed this May 3, 2012

Contributor

dominic-p commented May 3, 2012

Thanks. I can't believe I missed the .paused() method. It works perfectly.

jorrit commented Jun 20, 2012

paused() doesn't appear on http://videojs.com/docs/api/. Perhaps it can be added.

Owner

heff commented Jun 20, 2012

Ah, yep. Thanks. Added it to the source and will go out with the next update.

On Jun 20, 2012, at 5:24 AM, Jorrit Schippers wrote:

paused() doesn't appear on http://videojs.com/docs/api/. Perhaps it can be added.


Reply to this email directly or view it on GitHub:
zencoder#181 (comment)

jorrit commented Aug 27, 2012

No update has happened, apparently.

@heff heff added a commit to heff/video.js that referenced this issue Aug 31, 2015

@heff heff Updated the swf to v4.7.5 e768e2c

Btw, paused() doesn't correctly reflect isPlaying() because if the player is stuck on buffering/downloading the movie, pasued() will be false, while the video is not really playing.

@shaharmor 100% agree! I'm also looking for isPlaying() method cuz paused() == false only tells that it is not paused...

Was there ever a solution on this? I'm getting the same instance state and it's quite annoying.

Member

misteroneill commented Jul 6, 2016

My $0.02 here is to listen to various events to track that state. Something like:

var isPlaying = false;

player.on(['waiting', 'pause'], function() {
  isPlaying = false;
});

player.on('playing', function() {
  isPlaying = true;
});

The playing event definitely sounds like what you'd look for to determine that playback is beginning:

Playback is ready to start after having been paused or delayed due to lack of media data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment