HTML 5 视频自定义控件
与许多 Web 开发人员一样,我期待使用新的 HTML 5 标签来传输视频。浏览器支持肯定还不够广泛,因此使用 Flash/SWF 后备 是必须的。
这让我想到:在 Flash 中,可以在 HTML 5 中高度自定义播放控件(暂停、播放、停止、搜索、音量等)吗?有哪些选项可用于自定义视频控件的字形、图标和颜色?需要 JavaScript 吗?例如,以下页面根据浏览器呈现不同的控件 - 使用 FF3.5、Chrome 和 Safari 进行测试:
http ://henriksjokvist.net/examples/html5-video/
跨浏览器自定义和标准化控件,甚至匹配旧版浏览器使用的 Flash 控件,这真是太棒了。
Like many web developers I'm looking forward to streaming video that utilizes the new HTML 5 <video>
tag. Browser support definitely isn't wide enough yet, so using a Flash/SWF fallback is a must.
This got me thinking: in Flash it's possible to highly customize the playback controls (pause, play, stop, seek, volume, etc.) in HTML 5?. What options are there for customizing the glyphs, icons and colors of video controls? Is Javascript required? For instance the following page renders different controls depending on the browser - tested using FF3.5, Chrome and Safari:
http://henriksjokvist.net/examples/html5-video/
It would be really awesome to customize and standardize controls across browsers and even match the Flash controls used by older browsers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 HTML5 规范中,有一个
controls
属性对于<视频>
。另请查看这篇文章:网络视频 - 深入了解 HTML5。它解释说:
In the HTML5 spec, there is a
controls
attribute for<video>
.Also check out this article: Video on the Web - Dive into HTML5. It explains:
YouTube 目前正在运行 HTML5 测试版。您可以通过访问 http://www.youtube.com/html5 激活它。目前,激活 Beta 版后,并非所有视频都以 HTML5 格式显示。 HTML5 中显示的视频会采用不同的加载动画,以便您识别它们(例如 http:// www.youtube.com/watch?v=KT1wdjlbyFc)。
正如您所看到的,他们的视频播放器看起来与 Flash 版本相同。
YouTube is currently running a HTML5 beta. You can activate it by visiting http://www.youtube.com/html5. Currently not all Videos are displayed in HTML5 after activating the beta. Videos displayed in HTML5 get a different loading animation so you can identify them (like this one http://www.youtube.com/watch?v=KT1wdjlbyFc).
As you can see their video player just looks the same as the flash version.
对于那些对出色的跨浏览器 HTML5 视频播放器感兴趣的人,请查看 Vimeo (http://vimeo.com )正在做。使用支持 HTML5 的浏览器(至少适用于 Safari、Chrome 和 IE9)访问任何视频,然后选择“切换到 HTML5 播放器”。
他们实现了自定义 HTML 控件,完全复制了 Flash 播放器的外观和感觉。这些控件在浏览器中看起来是相同的。
迄今为止我见过的最好的跨浏览器实现。他们甚至使用
元素来为音量选择器设置动画。
For those interested in a great cross-browser HTML5 video player, check-out what Vimeo (http://vimeo.com) is doing. Visit any video with an HTML5-capable browser (works with at least Safari, Chrome, and IE9) and choose to "Switch to HTML5 Player."
They've implemented custom HTML controls that fully replicate their Flash-player look-and-feel. The controls look identical across browsers.
Best cross-browser implementation I've seen to-date. They even use a
<canvas>
element to animate the volume selector.我的猜测是,控件的外观取决于浏览器(因此不太可定制)。通过将测试页面提交到 Litmus,您可以看到测试页面在所有浏览器中的外观。
My guess is that the appearance of the controls is browser-dependent (and hence not very customizable). You could see what your test page looks like in all the browsers by submitting it to Litmus.
使用可访问的 Google 字体图标和 wcag https://jsfiddle.net/j0q4nxp9/1/
Using google font icons and wcag accessible https://jsfiddle.net/j0q4nxp9/1/