可以
- function param(name){
- var match = new RegExp(name+"=([^&]+)").exec(location.href);
- return match ? match[1] : null;
- }
- var type='video/mp4';
- if(param('url').indexOf('.m3u8')>-1){
- type='application/x-mpegURL';
- }
- else if(param('url').indexOf('.mkv')>-1){
- type='video/x-matroska';
-
-
- }
- var options = {
- playbackRates: [0.5,1,1.5,2,3],
- sources: [{
- src: param('url'),
- type: type
- }]
- };
- var player = videojs('playerCnt', options, function onPlayerReady() {
- videojs.log('播放器已准备就绪!');
- this.play();
- this.on('ended', function() {
- videojs.log('啊...这么快就结束了?!');
- });
- });
复制代码 |