如何使用javascript将vimeo视频源更改为本地mp4视频
how to change vimeo video source to local mp4 video using javascript
我正在尝试制作一个包含vimeo和本地视频的视频播放器,但我不知道如何将视频源切换到本地视频,如果vimeo视频无法播放。我用的是video.js.请帮忙:)
这是我的代码:
HTML<video id="vid1" src="" class="video-js vjs-default-skin" controls preload="auto" width="640" height="360">
Javascript: videojs('vid1', { "techOrder": ["vimeo"], "src": "https://vimeo.com/63186969" }).ready(function() {
// You can use the video.js events even though we use the vimeo controls
// As you can see here, we change the background to red when the video is paused and set it back when unpaused
this.on('pause', function() {
document.body.style.backgroundColor = 'red';
});
this.on('play', function() {
document.body.style.backgroundColor = '';
});
// You can also change the video when you want
// Here we cue a second video once the first is done
this.one('ended', function() {
this.src('http://video-js.zencoder.com/oceans-clip.mp4');
this.play();
});
我做了一些改变我的js,但仍然无法改变。我是javascript新手,请帮助我:)
Javascript:videojs('vid2', { "techOrder": ["vimeo"], "src": "https://vimeo.com/63186969" }).ready(function() {
// You can use the video.js events even though we use the vimeo controls
// As you can see here, we change the background to red when the video is paused and set it back when unpaused
this.on('pause', function() {
document.body.style.backgroundColor = 'red';
});
this.on('play', function() {
document.body.style.backgroundColor = '';
});
// You can also change the video when you want
// Here we cue a second video once the first is done
this.one('ended', function() {
this.src('http://vimeo.com/79380715');
this.play();
});
myPlayer.src("http://video-js.zencoder.com/oceans-clip.mp4");
var myPlayer = videojs('vid2');
myPlayer.ready(function(){ /*Video is ready*/ });
myPlayer.error(function(){ /*An error happened*/ });
mpPlayer.play();
]);
这里有两个事件:
var myPlayer = videojs('example_video_1');
myPlayer.ready(function(){ /*Video is ready*/ });
myPlayer.error(function(){ /*An error happened*/ });
更多api信息在这里:https://github.com/videojs/video.js/blob/master/docs/api/vjs.Player.md
相关文章:
- VideoJS:mp4在动态更改视频url时不起作用
- 三星智能电视视频播放器应用程序-访问存储在USB上的mp4
- Node.js:获取一个mp4文件的视频和音频格式信息
- 通过javascript播放mp4视频
- 如何使用vanillaJS将mp4视频插入到具有特定维度的html文档中,播放2秒,然后删除节点
- 当链接中引用视频时,是否可以在iPad上以全屏模式打开.mp4
- 无法在浏览器中播放MP4视频
- 火狐 10.0.1 不播放 html mp4 视频
- Chrome中的HTML5视频在mp4下不起作用
- YouTube嵌入式播放器将视频下载为MP4按钮属性
- 如何在 MVC 中播放视频时停止滑块.mp4
- HTML5读取mp4的视频元数据
- mencoder 从 html 视频标签镶边中的 JPG 播放停止生成 MP4 H.264
- Flowplayer中的MP4视频无法在Windows 7 Chrome中播放
- 使用Javascript下载HTML5 mp4视频
- 如何使用servlet和jsp在浏览器上播放视频,视频存储在本地系统中,如D:/video/sample.mp4
- 用JavaScript创建MP4视频
- JW播放器-当其他媒体(RTMP)断开连接时,循环MP4待机视频
- 如何将网页渲染视频保存到mp4-Diaporama
- 视频.mp4赢得'不要在任何浏览器中显示