Is there a way to make HTML5 video fullscreen?

2019-01-02 17:53发布

Is there a way to play a video fullscreen using the HTML5 <video> tag?

And if this is not possible, does anybody know if there is a reason for this decision?

20条回答
浮光初槿花落
2楼-- · 2019-01-02 17:57

An alternative solution would be to have to browser simply provide this option on the contextual menu. No need to have Javascript to do this, though I could see when it would be useful.

In the mean time an alternative solution would simply be to maximise the window (Javascript can provide screen dimensions) and then maximise the video within it. Give it a go and then simply see if the results are acceptable to your users.

查看更多
零度萤火
3楼-- · 2019-01-02 17:58

As of Chrome 11.0.686.0 dev channel Chrome now has fullscreen video.

查看更多
旧人旧事旧时光
4楼-- · 2019-01-02 18:01

Yes. Well what happens with HTML5 video is that you just put the <video> tag and the browser will give it's own UI, and thus the ability for full screen viewing. It really makes life much better on us users to not have to see the "art" some developer playing with Flash could make :) It also adds consistency to the platform, which is nice.

查看更多
余生请多指教
5楼-- · 2019-01-02 18:03
webkitEnterFullScreen();

This needs to be called on the video tag ele­ment, for example, to full­screen the first video tag on the page use:

document.getElementsByTagName('video')[0].webkitEnterFullscreen();

Notice: this is outdated answer and no longer relevant.

查看更多
听够珍惜
6楼-- · 2019-01-02 18:03

From CSS

video {
    position: fixed; right: 0; bottom: 0;
    min-width: 100%; min-height: 100%;
    width: auto; height: auto; z-index: -100;
    background: url(polina.jpg) no-repeat;
    background-size: cover;
}
查看更多
孤独总比滥情好
7楼-- · 2019-01-02 18:07

it's simple, all the problems can be solved like this,

1) have escape always take you out of fullscreen mode (this doesn't apply to manually entering fullscreen through f11)

2) temporarily display a small banner saying fullscreen video mode is entered (by the browser)

3) block fullscreen action by default, just like has been done for pop-ups and local database in html5 and location api and etc, etc.

i don't see any problems with this design. anyone think i missed anything?

查看更多
登录 后发表回答