Play youtube video in fullscreen on button click on mobile browsers

回眸只為那壹抹淺笑 提交于 2020-01-13 03:51:50

问题


I want to play a youtube video in fullscreen on click of a button. I currently have the following iframe:

<div class="youtube-trailer">
    <iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/whatever" allowfullscreen frameborder="0"></iframe>
</div>

On Safari Mobile, specifically, when a press the Play button the video launches in full screen which is the desired behavior. This is fine. I don't want the iframe displayed on the page though. I just want a button that will open the video in fullscreen using the native video player. i.e. i don't want to create an overly-elaborate lightbox to house the video.

Anyone have any ideas?


回答1:


The standard youtube video link format is:

http://www.youtube.com/watch?v=Lv-sY_z8MNs

You can link directly to the full screen video (without opening a new window) by adding "_popup" after "watch" in the URL:

http://www.youtube.com/watch_popup?v=Lv-sY_z8MNs

This should work for both mobile and desktop browsers. Naturally, if you did end up wanting to open your link in a new page, simply add "target="_blank" to your opening anchor tag.



来源:https://stackoverflow.com/questions/16763496/play-youtube-video-in-fullscreen-on-button-click-on-mobile-browsers

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