【发布时间】:2017-05-08 14:11:56
【问题描述】:
我在这个问题上尝试了一些方法,但我找不到它,我正在使用带有 contrib hls 的 videojs,它是第一次工作。
使用 m3u8 文件,当我第一次使用 ngOnit 调用 videojs 时,它可以正常工作,但是如果我更改动态 src url,它会显示错误,我只是更改 src url 并附加到视频 js src,但这里我由于服务器或网络错误,无法加载媒体。但是如果我使用 mp4 mime 类型它工作正常,并且更改动态 src url 也可以工作,任何人都可以帮助我处理这个带有 m3u8 文件的 hls 吗?
使用这些 videojs 文件:index.html
<link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
<script src="//vjs.zencdn.net/5.11/video.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/3.6.4/videojs-contrib-hls.min.js"></script>
组件代码
export class PlayVideoComponent implements OnInit, AfterViewInit {
@Input() selectedVideo: VideoFile;
public videoUrl: string;
private videoJSplayer: any;
constructor(private authenticationService: AuthenticationService){}
selectedVideo(video:VideoFile) { // passing new video object
this.selectedVideo = video;
this.videoUrl = this.selectedVideo.videoPath;
this.videoUrl = this.videoUrl + '?access_token='+ this.authenticationService.access_token;
}
ngOnInit() {
this.videoUrl = this.selectedVideo.videoPath;
this.videoUrl = this.videoUrl + '?access_token='+ this.authenticationService.access_token;
console.log('video url is ' + this.videoUrl);
}
ngAfterViewInit() {
this.videoJSplayer = videojs('example_video_11', {}, function() {
this.play();
});
}
组件html代码:
<video id="example_video_11" class="video-js vjs-default-skin"
controls preload="auto" data-setup='{"example_option":true}'>
<source [src] = videoUrl type="application/x-mpegURL" />
</video>
【问题讨论】:
标签: angular video.js http-live-streaming m3u8