Reputation: 9126
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.
Upvotes: 1
Views: 1280
Reputation: 153
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.
Upvotes: 1
Reputation: 9126
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.
Upvotes: 0
Reputation: 18761
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
Upvotes: 1