html 如何从视频标签的事件中获取关于.m3u8或. ts文件的字符串值?

5w9g7ksd  于 2022-12-09  发布在  其他
关注(0)|答案(1)|浏览(166)

我想处理字符串值从.m3u8或. ts文件(下面)的Javascript。
我可以通过视频标签事件访问这些信息(转换后的字符串或JSON)吗?或者有什么方法吗?

#EXTM3U
#EXT-X-TARGETDURATION:3.84
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:3.84,
some_url/1/some_file1.ts?from=0&to=3840
#EXTINF:1.728,
some_url/1/some_file2.ts?from=0&to=3840
#EXT-X-ENDLIST
hc8w905p

hc8w905p1#

you can go through https://github.com/video-dev/hls.js/blob/master/docs/API.md#ploader and change the class this way to get the data you displayed.

class pLoader extends Hls.DefaultConfig.loader{
constructor(config) {
 super(config);
 var load = this.load.bind(this);
 this.load = function (context, config, callbacks) {
  if (context.type == 'level') {
    var onSuccess = callbacks.onSuccess;
    callbacks.onSuccess = function (response, stats, context) {
      console.log(response.data);
      onSuccess(response, stats, context);
    };
 }
  load(context, config, callbacks);
};

} };

相关问题