我遵循shaka的基本用法来处理DASH视频,但在尝试加载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相关的东西。
有什么提示吗?非常感谢!
发布于 2020-06-26 23:03:45
事实证明,它只需添加以下内容即可工作
<script src="https://github.com/videojs/mux.js/releases/latest/download/mux.js"></script>
到Angular的index.html。导入不起作用。不需要进行额外的配置。Shaka会检测到它并使用它。
而是因为我想要keep the dependency inside the app。我将js复制到assets文件夹(as referencing from node modules does not work。
<script defer src="assets/mux.min.js"></script>遗憾的是,从angular.json脚本引用也不起作用。
发布于 2021-01-06 17:19:34
尝试对import执行此操作以保留依赖关系:
import muxjs from 'mux.js';
interface MyWindow extends Window {
muxjs: string;
}
(window as MyWindow & typeof globalThis).muxjs = muxjs;https://stackoverflow.com/questions/62596654
复制相似问题