在按钮上单击移动浏览器,全屏播放YouTube视频 [英] Play youtube video in fullscreen on button click on mobile browsers

查看:195
本文介绍了在按钮上单击移动浏览器,全屏播放YouTube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想点击一个按钮全屏播放YouTube视频。我目前有以下 iframe

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>

在Safari Mobile上,特别是当按下播放按钮时,视频将以全屏模式启动,即期望的行为。这可以。我不希望页面上显示 iframe 。我只想要一个按钮,使用原生视频播放器全屏打开视频。即我不想创建一个过于精心设计的灯箱来容纳视频。

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?

推荐答案

标准的YouTube视频链接格式为:

The standard youtube video link format is:

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

您可以直接链接到全屏视频(不打开新窗口)在URL中watch之后添加_popup:

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

这应该适用于移动设备和桌面浏览器。当然,如果您最终想要在新页面中打开链接,只需将target =_ blank添加到您的开始锚标记中。

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.

这篇关于在按钮上单击移动浏览器,全屏播放YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆