gpt4 book ai didi

javascript - videojs 以编程方式更改音轨

转载 作者:行者123 更新时间:2023-12-01 02:14:15 27 4
gpt4 key购买 nike

我已经阅读了文档两次,但还没有找到一种方法来做到这一点。 videojs其本身无法做到这一点,文档中提到了这一点,所以我有 hls插件应该能够做到这一点,但我找不到任何与此相关的内容。

有人能指出我正确的方向吗?

最佳答案

以下是使用 video.js 更改源视频轨道的示例:

/* video player setup */
vPlayer = videojs('my_video', {
techOrder: ["html5", "youtube"],
autoplay: false,
sources: [{
type: "video/mp4",
src: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
}]
});
vPlayer.on('playing', function(e) {
$("#info").html("playing...<br>url: " + vPlayer.currentSrc() + "<br>type:" + vPlayer.currentType());
});

/* available videos */
var vids = [{
type: "video/mp4",
src: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
},
{
type: "video/mp4",
src: "https://vjs.zencdn.net/v/oceans.mp4"
},
{
type: "video/youtube",
src: "https://www.youtube.com/watch?v=kkGeOWYOFoA"
}
];

playVideo = function(n) {
vPlayer.src(vids[n]);
vPlayer.play();
}
<link href="https://vjs.zencdn.net/6.7/video-js.css" rel="stylesheet"/>
<script src="https://vjs.zencdn.net/6.7/video.js"></script>
<script src="https://cdn.rawgit.com/videojs/videojs-youtube/c4be481f/dist/Youtube.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<video id="my_video" class="video-js vjs-default-skin" controls preload="auto" width="640" height="400">
</video>
<hr>
<button onclick="playVideo(0)">play 0 (mp4)</button>
<button onclick="playVideo(1)">play 1 (mp4)</button>
<button onclick="playVideo(2)">play 2 (youtube)</button>
<hr>
<div id="info"></div>

这里还有一个jsfiddle:https://jsfiddle.net/beaver71/w7yah2vo/

关于javascript - videojs 以编程方式更改音轨,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49568849/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com