我遵循适用于 DASH 视频的 shaka 的基本用法,但在尝试加载 M3U8 时会抛出错误代码 4032。
import * as muxjs from 'mux.js';
import * as shaka from 'shaka-player';
export class AppComponent implements AfterViewInit {
@ViewChild('videoPlayer') videoElementRef: ElementRef;
videoElement: HTMLVideoElement;
manifestUri = 'http://hlsliveamdgl7-lh.akamaihd.net/i/hlsdvrlive_1@583042/master.m3u8';
ngAfterViewInit() {
shaka.polyfill.installAll();
this.videoElement = this.videoElementRef.nativeElement;
this.initPlayer();
}
private initPlayer() {
shaka.media.ManifestParser.registerParserByExtension("m3u8", shaka.hls.HlsParser);
shaka.media.ManifestParser.registerParserByMime("Application/vnd.apple.mpegurl", shaka.hls.HlsParser);
shaka.media.ManifestParser.registerParserByMime("application/x-mpegURL", shaka.hls.HlsParser);
let player = new shaka.Player(this.videoElement);
player.load(this.manifestUri).then(() => {
// This runs if the asynchronous load is successful.
console.log('The video has now been loaded!');
}).catch(this.onError); // onError is executed if the asynchronous load fails.
}
模板是
<video #videoPlayer
id="video"
width="640"
poster="https://upload.wikimedia.org/wikipedia/commons/c/c4/PM5544_with_non-PAL_signals.png"
controls> </video>
相关的 Angular 9 依赖项是
"shaka-player": "^3.0.1",
并且还安装了(可能没有必要)
"hls.js": "^0.13.2",
"mux.js": "^5.6.4",
在 Safari 上它可以工作,而不是在 Chrome 上。我想我遗漏了一些与 mux.js 相关的东西。
有什么提示吗?非常感谢!