1

Is it possible, using javascript, to detect if an embedded youtube video pauses playback in order to let the video buffer? I know that there are events that fire when the user presses pause, but I'm looking for an event that fires when the video pauses due to a slow connection. I'm creating a web application where it's important to have the video play through smoothly. If the video pauses due to a slow connection, I want to detect that.

3 Answers 3

1

Use this code player.getPlayerState():Number it seems like you are allowed to ask the player what status it is in so this may help you
https://developers.google.com/youtube/js_api_reference

Sign up to request clarification or add additional context in comments.

Comments

1

There is also a state 'buffering' being fired when the player needs to buffer more data..in that case the video stops. I guess also 'error' state might be of help.

Comments

0

The solution I worked out is just to use the javascript API's onStateChange callback (https://developers.google.com/youtube/js_api_reference) to detect when the player is started for the first time and when it finishes playing at the end. When the player is started, I grab the current time. When it finishes, it sees how much time has elapsed. In my application, the user cannot pause the video, so comparing the elapsed time to the video length indicates if it paused for loading.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.