当前位置:网站首页>让知识付费系统视频支持M3U8格式播放的方法
让知识付费系统视频支持M3U8格式播放的方法
2022-06-22 19:10:00 【withkai44】
当前知识付费使用阿里云 web 播放器作为视频播放器。阿里云 web 播放器本身支持 MP4 和 M3U8 格式播放,由于知识付费底层引入 RequireJS,导致阿里云 web 播放器 Hls 扩展插件变成 AMD 模块,从而将 Hls 未被全局暴露,进而导致知识付费目前只支持 MP4 格式播放。
让知识付费支持 M3U8 格式,就需要将 Hls 全局暴露。目前有两种方法,一种是在引入 RequireJS 之前使用 script 标签引入 hls.js 文件,这样就可以避免在引入 hls.js 文件之前全局环境已经存在 define.amd,从而暴露 Hls 全局变量。另一种是使用 RequireJS 的 require() 引入 hls.js,然后将 Hls 挂载到全局对象。
script 标签引入
如上图所示,必须写在 block name=”head_top” 模块中,否则无效。因为这个 block 在 requirejs 所在 block 之前。这里的 block 属于 thinkphp 内容。
如上图所示,这是 aliplayer.js 中对于 Hls 的使用,故而 Hls 必须挂载到全局对象,否则不能获取到 Hls 对象。
require() 引入
如上图,在 require.config 的 paths 中配置好 aliplayer、aliplayer-hls 和 aliplayer-plugin。其中 aliplayer-plugin 是作为中间模块使用。
如上图所示,这是 aliplayer-plugin 模块,在这个模块中将 Hls 挂载到全局对象。这样整个流程就可以正常运行。
其实两种方法的最终目的都是将 Hls 暴露出来,这样后续功能才可以正常运行,不管哪一种方法,主要看整个项目规范和功能实现的难易程度。具体运行中会怎么样,还需要不断地测试和读懂 aliplayer 在一些关键点的处理方式。
欢迎技术交流 QQ: 735660248
边栏推荐
- 一文搞懂 MySQL 中 like 的索引情况
- 科技云报道:东数西算不止于“算”,更需“新存储”
- From perceptron to transformer, a brief history of deep learning
- Raspberry pie environment settings
- Cloud computing in the metauniverse to enhance your digital experience
- He was in '98. I can't play with him
- Oh, my God, it's a counter attack by eight part essay
- 6月第3周B站榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
- Kotlin1.6.20新功能Context Receivers使用技巧揭秘
- JWT简介
猜你喜欢

ROS from entry to mastery (VIII) common sensors and message data

MySQL Basics - functions

IDEA写jsp代码报错,但是正常运行解决
Summary of 2019: 31 is just another start

Three dimensional world helps the laboratory to consolidate the complete quality system management

Classic interview question: a page from entering URL to rendering process

深度学习常用损失函数总览:基本形式、原理、特点

MySQL基础——约束

AAAI 2022 | traditional Gan can be interpreted after modification, and the interpretability of convolution kernel and the authenticity of generated image are guaranteed

#夏日挑战赛# 【FFH】从零开始的鸿蒙机器学习之旅-NLP情感分析
随机推荐
Redis中的Multi事务
MySQL基础——约束
Cross domain cors/options
Recv function with timeout
MySQL高级(二)
ZABBIX learning notes (37)
Using qtest for data set test performance test GUI test
Raspberry pie environment settings
播放增长900w,B站用户叫好叫座的恰饭总结
Multi transactions in redis
web技术分享| 【高德地图】实现自定义的轨迹回放
【Proteus仿真】三极管组成的H桥驱动直流电机+按键正反转控制
[proteus simulation] H-bridge drive DC motor composed of triode + key forward and reverse control
leetcode.11 --- 盛最多水的容器
CVPR 2022 oral | video text pre training new SOTA, HKU and Tencent arc lab launched excuse task based on multiple-choice questions
Web technology sharing | [Gaode map] to realize customized track playback
2019 年总结:31岁,不过是另一个开始
Zabbix学习笔记(三十七)
【Proteus仿真】NE555延时电路
同花顺开户选哪家券商比较好?手机开户安全么?