How to control iframe based YouTube player?

YouTube allows you to use <iframe> to embed videos on sites in addition to the built-in flash embed method. This has advantages, especially for mobile devices. http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

Unfortunately, I could not find the API documentation similar to a flash interface, for example http://code.google.com/apis/youtube/js_api_reference.html

Is it possible to programmatically control the <iframe> player using pure JavaScript, for example, playing or pausing a video?

+4
source share
1 answer

https://developers.google.com/youtube/iframe_api_reference#Operations

We support a similar feature set for the IFrame API, as is currently supported for the JavaScript API.

Please refer to this document for a list of features. Note that the functions associated with video bytes behave differently when HTML5 playback is used through the IFrame API. getVideoBytesTotal is tightly bound to return 1000. getVideoBytesLoaded will return a value from 0 to 1000. To calculate the proportion of the video that has been uploaded, you can split the getVideoBytesLoaded getVideoBytesTotal value and that calculation will work regardless of whether HTML5 or ActionScript 3 plays.

Please note that this is an experimental service that should not be used for production-level applications.

Note

Important: this is experimental, which means that it can change unexpectedly.

+3
source

All Articles