ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

javascript – 如何控制基于YouTube的播放器?

2019-06-30 17:22:35  阅读:181  来源: 互联网

标签:javascript youtube html5-video


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

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

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

解决方法:

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

We support a similar set of functions
for the IFrame API as are currently
supported for the JavaScript API.

Please refer to that document for a
list of functions. Please note that
the functions that deal with video
bytes behave differently when HTML5
playback is used via the IFrame API.
getVideoBytesTotal is hardcoded to
return 1000. getVideoBytesLoaded will
return a value between 0 and 1000. To
calculate the fraction of the video
that has been loaded you can divide
the getVideoBytesLoaded value by the
getVideoBytesTotal value, and that
calculation will work regardless of
whether HTML5 or ActionScript 3
playback is used.

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

注意

Important: This is an experimental
feature, which means that it might
change unexpectedly.

标签:javascript,youtube,html5-video
来源: https://codeday.me/bug/20190630/1338698.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有