Full Screen Option in Chromeless player using Javascript?

时光毁灭记忆、已成空白 提交于 2020-01-01 18:21:10

问题


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 ?


回答1:


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.

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();
}


来源:https://stackoverflow.com/questions/13120704/full-screen-option-in-chromeless-player-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!