javascript - 使用javascript单击按钮后如何更改视频源
问题描述
我想在单击按钮后执行更改视频源的功能。但是,我使用了很多方法,但是点击后,视频播放器仍然没有更改源。这是我的代码:(我省略了一些不必要的代码)HTML:
<video id="my-player">
<source id='source' src='' type="application/dash+xml"></source>
<p class="vjs-no-js">
</video>
<button id='dashsample' onclick='dashSample(); return false'>Dash Sample</button>
Javascript:
function dashSample(){
var video = document.getElementById('my-player');
var source = document.getElementById('source');
var newsource = 'http://dai-ce14453a15d70c42.elb.eu-central-1.amazonaws.com/awt/media/dash/cosmo/cosmo1/manifest.mpd';
source.setAttribute('src',newsource);
video.load();
//play when ready
video.play();
}
太感谢了!
解决方案
推荐阅读
- javascript - 自定义加载器不适用于 react-table
- sql - VERTICA:如何创建循环
- reactjs - React Redux:更新对象正在更新状态但未触发选择器
- x86 - 适用于 x32 和 x64 文件的 VS 安装程序
- javascript - 将 JSON 从 quill 导出到数据库
- android - 带有 ID 的房间查询返回 null
- c# - C# 如何检查下载的 zip 存档是否损坏(“找不到中央目录记录结束”异常)
- html - 如何在图片标签内使用 Base64 SVG 占位符
- flutter - Flutter:使用手势检测器禁用多点触控/拖动
- keras - 在训练图像相似性神经网络时如何使用 L1 距离?