简体   繁体   English

html5:在控件视频中添加下载按钮

[英]html5 : add download button in controls video

is it possible to add download button in controls video like in chrome 55+ to implement in other browser? 是否可以在控件视频(例如chrome 55+)中添加下载按钮以在其他浏览器中实现?

if it possible, how can I add that? 如果可能的话,如何添加呢?

In summary, you need to make video control panel yourself, based on video's javascript API. 总而言之,您需要根据视频的javascript API自己制作视频控制面板。 Some libraries may become a good start, such as Player.js etc. 一些库可能是一个不错的开始,例如Player.js等。

When you customize the video control, you can use download attribute of <a> element to implement the download button: 自定义视频控件时,可以使用<a>元素的download属性来实现下载按钮:

<a href="/sampleVideo.mp4" download><span class="icon-download"></span></a>

Below is some detail explanation: 以下是一些详细说明:


For control attribute of <video> , you cannot customize its UI. 对于<video> control属性,您无法自定义其UI。 Unfortunately, in HTML5 specification , "download button" is not in the list of "should include features" of control : 不幸的是,在HTML5规范中 ,“下载按钮”不在control的“应包括功能”列表中:

If the attribute is present, or if scripting is disabled for the media element, then the user agent should expose a user interface to the user. 如果存在该属性,或者如果禁用了Media元素的脚本,则用户代理应向用户公开用户界面。 This user interface should include features to begin playback, pause playback, seek to an arbitrary position in the content (if the content supports arbitrary seeking), change the volume, change the display of closed captions or embedded sign-language tracks, select different audio tracks or turn on audio descriptions, and show the media content in manners more suitable to the user (eg full-screen video or in an independent resizable window). 此用户界面应具有以下功能:开始播放,暂停播放,在内容中查找到任意位置(如果内容支持任意查找),更改音量,更改隐藏字幕或嵌入式手语轨道的显示,选择其他音频跟踪或打开音频描述,并以更适合用户的方式显示媒体内容(例如,全屏视频或在独立的可调整大小的窗口中)。 Other controls may also be made available. 也可以使用其他控件。

In my experiment, I find Chrome 58 and Opera 44 have download button in the video control, while Safari and Firefox does not. 在我的实验中,我发现Chrome 58和Opera 44在视频控件中都有下载按钮,而Safari和Firefox没有。

However, you can still use video's DOM API to construct your own control panel (start, pause, resume, mute etc). 但是,您仍然可以使用视频的DOM API来构建自己的控制面板(开始,暂停,恢复,静音等)。 Player.js is a good example, it demonstrate what you can do based on the native JavaScript API. Player.js是一个很好的例子,它演示了基于本机JavaScript API可以执行的操作。

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

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