javascript - 如何在这个 JavaScript 播放器中嵌入 youtube 视频?”
问题描述
我需要在这个播放器上放一个 YouTube 视频:https ://www.w3schools.com/html/mov_bbb.mp4 我必须嵌入一个 youtube 视频我不知道该怎么做
如果有人可以帮助我,我是编程新手
<center><div id="myVideoSources" style="display:none;">
<source class="active" src="https://www.w3schools.com/html/mov_bbb.mp4" id="videoSource" type="video/mp4" startat="00:00:00" endat="00:00:10" name="Something" description="This is Gujarati Videol">
<source class="active" src="https://lh3.googleusercontent.com/lKr008DzBwztuG0f15-hzojP7ACJOlV10WrcFfhp9SWCok4igE4nT
tkCpcETaxvGF5m5tMgZPhkCPyiiueqcdV6d6yR3lM3ERPfRz5jkvrsM_y3xjq1o3GLnazLBEEOUaAbMS86y4g=m22" id="videosource2" type="video/mp4" startat="00:00:00" endat="03:02:02" name="PHP Video " description="This is PHP Video">
</div>
<video id="media-video" controls width="340" height="200"></video>
<script>
$(function () {
var sources = $("#myVideoSources source");
var jVideo = $("#media-video");
var currentVideoNum = 0;
loadNextVideo();
jVideo.bind("ended", function () {
loadNextVideo();
});
function loadNextVideo() {
var source = $(sources.get(currentVideoNum));
currentVideoNum++;
if(currentVideoNum >= sources.length) {
currentVideoNum = 0;
}
jVideo.html("");
jVideo.append(source);
var plainVideo = jVideo.get(0);
plainVideo.load();
plainVideo.play();
plainVideo.currentTime = getStartTime(source);
}
function getStartTime(source) {
var time = 0;
try {
var startAtStr = source.attr("startat");
time = startAtStr.split(":");
time = (time[0] * 3600) + (time[1] * 60) + (time[2] * 1)
} catch(e) {
console.log(e);
time = 0;
}
return time;
}
});
</script></center>
解决方案
推荐阅读
- qt - QtQuick 2.12 中的垂直滑动
- c - zsh shell 中的百分号从何而来?
- javascript - Angular 上的缓存破坏
- docker - 如何使用自定义配置通过 docker 运行 hyperledger besu 节点?
- python - 如何绘制用于分组子图的括号
- javascript - 在 JS 中监听基础切换器
- docker - 在 windows 10 pro 上安装 Docker 失败:需要 Windows 10 Pro/Enterprise/Home (18363+)
- tensorflow - 构建用于参数预测的自动编码器网络
- javascript - 如果我使用 cypress-cucumber,是否必须为每个功能文件创建步骤定义文件夹?
- javascript - opencv.js Mat乘法与标量