javascript - 如何使用 Plyr JS 在视频播放器中添加下载按钮?
问题描述
我正在使用Plyr JS
并希望download
为每个video
.
这是我试图download option
提供的内容:
尽管我提供了: controlsList="nodownload"
<video controls crossorigin playsinline controlsList="nodownload" poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" id="player">
<source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4" type="video/mp4" size="576">
</video>
问题:如何使下载选项仅使用Plyr.io
插件显示?
解决方案
您可以使用 Plyr JS 自定义所有 Plyr 控件。这是来自官方来源的完整描述。
控件
这是为 Plyr 控件呈现的标记。您可以使用默认控件或根据您的需要提供自定义版本的标记。您可以将以下内容传递给控制选项:
Array
选项(这会根据您的选择构建默认控件)Element
与控件String
包含所需的 HTMLfalse
(或空字符串或数组)禁用所有控件Function
将被执行并应返回上述之一
演示:CodePen.io 上带有自定义控件(包括下载按钮)的Plyr 播放器
在 StackOverflow 片段中,下载按钮不起作用,因为它位于沙箱中。请参阅 CodePen.io 上的演示(上面的链接)。
Array
带有选项的示例:
var controls =
[
'play-large', // The large play button in the center
'restart', // Restart playback
'rewind', // Rewind by the seek time (default 10 seconds)
'play', // Play/pause playback
'fast-forward', // Fast forward by the seek time (default 10 seconds)
'progress', // The progress bar and scrubber for playback and buffering
'current-time', // The current time of playback
'duration', // The full duration of the media
'mute', // Toggle mute
'volume', // Volume control
'captions', // Toggle captions
'settings', // Settings menu
'pip', // Picture-in-picture (currently Safari only)
'airplay', // Airplay (currently Safari only)
'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
'fullscreen' // Toggle fullscreen
];
var player = new Plyr('#player', { controls });
推荐阅读
- python - “set”类型的对象不是 JSON 可序列化的
- sql - 查询以根据 UI 中的搜索条件从多个表中选择记录
- search - 对大于或等于给定键的元素进行二分查找
- python - Function to return the index at which a specific letter occurs always returns nothing regardless of input in Python?
- git - 如何忽略“git存档”中的文件/目录,只创建子目录的存档?
- android - 如何为字符串中的文本添加下划线?
- c - 在内核中使用 sock_create、accept、bind 等
- excel - 从工作表填充列表框时出现错误 381
- python - Trying a function to get data in separate ranges, tally it, and return a list of the tallies
- scala - Scala Slick and nested case classes