gpt4 book ai didi

javascript - 如何控制基于 <iframe> 的 YouTube 播放器?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:36 25 4
gpt4 key购买 nike

YouTube 允许使用 <iframe>除了基于 Flash 的嵌入方式之外,还可以在网站上嵌入视频。这尤其对移动设备具有优势。 http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

不幸的是,我找不到任何类似于 http://code.google.com/apis/youtube/js_api_reference.html 这样基于 flash 的方式的 API 文档。

是否可以通过编程方式控制 <iframe>基于播放器使用纯 JavaScript,例如播放或暂停视频?

最佳答案

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

We support a similar set of functionsfor the IFrame API as are currentlysupported for the JavaScript API.

Please refer to that document for alist of functions. Please note thatthe functions that deal with videobytes behave differently when HTML5playback is used via the IFrame API.getVideoBytesTotal is hardcoded toreturn 1000. getVideoBytesLoaded willreturn a value between 0 and 1000. Tocalculate the fraction of the videothat has been loaded you can dividethe getVideoBytesLoaded value by thegetVideoBytesTotal value, and thatcalculation will work regardless ofwhether HTML5 or ActionScript 3playback is used.

请注意,这是一项实验性服务,不应用于生产级应用程序。

注意事项

Important: This is an experimentalfeature, which means that it mightchange unexpectedly.

关于javascript - 如何控制基于 &lt;iframe&gt; 的 YouTube 播放器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6228923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com