我有一个m3u8文件,如下所示:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=2048805,CODECS="avc1.66.31,mp4a.40.2",RESOLUTION=1280x720
chunklist_w517510829.m3u8
尝试播放时出现以下错误:
Uncaught NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp2t; codecs="avc1.66.31,mp4a.40.2"') is unsupported.
player.js:1682 Uncaught TypeError: undefined is not a function
奇怪的是,如果我删除avc1.66.31,mp4a.40.2
,它在Chromecast上播放得很好。我将此示例用作播放器https://github.com/googlecast/Cast-Player-Sample
感谢。
答案 0 :(得分:2)
Chromecast的某些版本拒绝" avc1.66.31"因此建议使用" avc1.66.30"而是通过更新播放列表或使用host.processManifest解决方法
host.processManifest = function(manifest) {
return manifest.replace(/CODECS=\"avc1.66.([0-9]*)/g, 'CODECS=\"avc1.66.30');
};
在自定义接收器中。
答案 1 :(得分:0)
在新版的Chromecast中,我必须:
context.getPlayerManager().setMediaPlaybackInfoHandler((loadRequest, playbackConfig) => {
if (loadRequest.media.customData &&
loadRequest.media.customData.playbackConfig &&
loadRequest.media.customData.playbackConfig.manifestHandler) {
playbackConfig.manifestHandler = loadRequest.media.customData.playbackConfig.manifestHandler;
}
return playbackConfig;
});
然后我以这种方式加载媒体信息(从清单中删除avc1.100
格式行):
const mediaInformation = new window.cast.framework.messages.MediaInformation();
...
mediaInformation.hlsSegmentFormat = window.cast.framework.messages.HlsSegmentFormat.TS;
mediaInformation.customData = {
manifestHandler: manifest => {
const lines = manifest.split(/\n/);
const result = [];
let i = 0;
while(i < lines.length) {
if (lines[i].match(/avc1\.100\./)) {
i += 2;
} else {
result.push(lines[i]);
i++;
}
}
return result.join('\n');
}
}