简体   繁体   English

播放视频 HTML5

[英]Play video HTML5

Is there a ready to use code or some sort to enable the fullscreen button on Safari for the ?video?是否有现成的代码或某种代码来启用 Safari 上的全屏按钮?视频? Currently when the video is loaded, and click on it doesnt work.目前在加载视频时,单击它不起作用。

<video width="320" height="240" controls="controls" name="media" src="urlvideo">Text</video>

What types are supported for the video tag? video 标签支持哪些类型? Do i need to use type=audio/mp3 for playing mp3 and type=audio/wav etc....?我是否需要使用 type=audio/mp3 来播放 mp3 和 type=audio/wav 等....?

By they way, the video ui looks different on each browser or not working at all... is there a way to have them all the same look and feel and have them all work on all browsers?顺便说一句,视频用户界面在每个浏览器上看起来都不同,或者根本不工作……有没有办法让它们的外观和感觉都一样,并在所有浏览器上都工作?

纯 css,您可以使用 video::-webkit-media-controls-fullscreen-button{} 定位它,并且您需要参考此http://codesearch.google.com/codesearch/p#OAMlx_jo-ck/ src/third_party/WebKit/Source/WebCore/css/mediaControls.css

To play video when user clicks on it:在用户点击视频时播放视频:

    document.querySelctor('video').addEvenetListenr('click', function(){
         this.play()
    }, false);

To have fullscreen use Webkit and Gecko full screen API要全屏使用 Webkit 和Gecko 全屏 API

First, not all browsers have the same video codecs, so not all browsers can play the same videos.首先,并非所有浏览器都具有相同的视频编解码器,因此并非所有浏览器都可以播放相同的视频。 I would suggest looking here to choose a format that is supported by the browsers you are targeting:我建议在这里选择一种您所定位的浏览器支持的格式:
HTML5 Video Codec Support By Browser浏览器支持 HTML5 视频编解码器


For Safari specifically, I have gotten this JavaScript to work to get a video to play fullscreen:特别是对于 Safari,我已经让这个 JavaScript 工作来让视频全屏播放:

var vid = document.getElementById('video');
vid.webkitEnterFullscreen();
vid.play();

Also, check out this thread: Web App - iPad webkitEnterFullscreen - Programatically going full-screen video另外,请查看此线程: Web App - iPad webkitEnterFullscreen - 以编程方式进入全屏视频

Hope that helps!希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM