检测,如果客户端允许内嵌媒体播放的HTML5视频媒体播放、内嵌、客户端、视频

2023-09-06 00:40:48 作者:碍人

有没有检测一个客户端浏览器可以让一个好办法在线媒体播放的HTML5视频?

Is there a good way to detect if a client browser allows inline media playback for HTML5 video?

更新

我并不想简单地检测视频的支持。

I am not trying to simply detect video support.

我想检测一个视频只能播放全屏或还内嵌。因为在iPhone上的Safari iOS的视频只能在全屏播放,但在iPad上的视频,可以在线播放。而通过在线我的意思是,在页面,而无需切换到全屏。

I am trying to detect if a video can only play fullscreen or also inline. Because on the iPhone safari iOS videos only play in fullscreen, but on iPad videos may be played inline. And by inline I mean in the page without switching to fullscreen.

推荐答案

而该文件 IOS的​​具体考虑说:

目前,Safari浏览器优化了视频presentation为小屏幕   在iPhone或iPod touch上使用全屏幕视频播放视频   控制当屏幕被触摸时出现,并且视频缩放到   适合在纵向或横向模式下的屏幕。视频是不是presented   在该网页。高度和宽度属性只影响   空间分配上的网页,与对照组属性将被忽略。   这仅适用于Safari是真正的小屏幕设备。在Mac OS   X,Windows和iPad的Safari浏览器播放视频的内联,嵌入在   网页。

Currently, Safari optimizes video presentation for the smaller screen on iPhone or iPod touch by playing video using the full screen—video controls appear when the screen is touched, and the video is scaled to fit the screen in portrait or landscape mode. Video is not presented within the webpage. The height and width attributes affect only the space allotted on the webpage, and the controls attribute is ignored. This is true only for Safari on devices with small screens. On Mac OS X, Windows, and iPad, Safari plays video inline, embedded in the webpage.

的iOS

var videoIsFullscreen = screen.width < 320 &&
                        navigator.userAgent.indexOf("Safari") > -1 &&
                        navigator.userAgent.indexOf("Chrome") == -1 &&
                        navigator.userAgent.match(/(iPhone|iPod)/);

注意,即时通讯不知道小屏幕是320px的,你应该调整此值。

修改

看看这个post.

汇总:

var isSmallScreen = screen.width <= 320;
/// the shadows here
var isWideScreen = screen.width >= 568;

毕竟,我发现这个职位,可以帮助你多少

After all, I found this post that may help you much

Can我避免了自身的全屏视频播放器与HTML5的iPhone或Android?

机器人

How在Android浏览器在线播放HTML5视频

How to play inline html5 video in Android Browser

请注意,是Android原生浏览器还没有为Android浏览器。

Note that is for native Android Browser not for Android Chrome.