使用 Javascript 的 Chromeless 播放器中的全屏选项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13120704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Full Screen Option in Chromeless player using Javascript?
提问by Rishi Jogle
I am using Youtube Javascript API to develop chromeless player. Can you tell me How to Add / Develop "Full Screen Control" using Javascript on player ?
我正在使用 Youtube Javascript API 来开发 chromeless 播放器。你能告诉我如何在播放器上使用 Javascript 添加/开发“全屏控制”吗?
回答by Greg Schechter
This is not something that currently exists in the YouTube api. Instead you can use the javascript fullscreen api to provide the functionality. Details can be found on MDN here.
这不是 YouTube api 当前存在的东西。相反,您可以使用 javascript fullscreen api 来提供该功能。可以在此处的 MDN 上找到详细信息。
https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
The code sample would look something like this
代码示例看起来像这样
var player = new YT.player('#my-video');
// Once the user clicks a custom fullscreen button
var el = document.getElementById('#my-player-element-container');
if (el.requestFullScreen) {
el.requestFullScreen();
} else if (el.mozRequestFullScreen) {
el.mozRequestFullScreen();
} else if (el.webkitRequestFullScreen) {
el.webkitRequestFullScreen();
}