当前位置:网站首页>让知识付费系统视频支持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
边栏推荐
- 【毕业季】走一步看一步?一个自动化er对大学四年的思考
- 【Proteus仿真】74LS138译码器流水灯
- How to realize @ person function in IM instant messaging
- MySQL advanced (II)
- 元宇宙中的云计算,提升你的数字体验
- Classic interview question: a page from entering URL to rendering process
- What can the accelerated implementation of digital economy bring to SMEs?
- An IPFs enabled email - skiff
- Async-profiler介绍
- From perceptron to transformer, a brief history of deep learning
猜你喜欢

【Proteus仿真】8x8Led点阵数字循环显示
Summary of 2019: 31 is just another start

510000 prize pool invites you to join the war! The second Alibaba cloud ECS cloudbuild developer competition is coming

完全背包如何考虑排列问题

基于Sentinel的高可用限流系统的Grafana报表展示

软件压力测试有哪些方法,如何选择软件压力测试机构?
MySQL中如何计算同比和环比

Using qtest for data set test performance test GUI test

Easydss problem and solution summary
![[in depth understanding of tcapulusdb technology] introduction tcapulusdb problem summary](/img/2b/3ab5e247ac103728b4d3579c3c5468.png)
[in depth understanding of tcapulusdb technology] introduction tcapulusdb problem summary
随机推荐
密码学系列之:PKI的证书格式表示X.509
[deeply understand tcapulusdb technology] tcapulusdb table management - clean up table
三维天地助力实验室夯实完整质量体系管理
【深入理解TcaplusDB知識庫】部署TcaplusDB Local版常見問題
2019 年总结:31岁,不过是另一个开始
Introduction of neural network (BP) in Intelligent Computing
client-go gin的简单整合十一-Delete
AAAI 2022 | 传统GAN修改后可解释,并保证卷积核可解释性和生成图像真实性
Stochastic Adaptive Dynamics of a Simple Market as a Non-Stationary Multi-Armed Bandit Problem
6月第3周B站榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
leetcode.11 --- 盛最多水的容器
【深入理解TcaplusDB技术】单据受理之创建业务指南
Redis中的Multi事务
Unityeditor editor script execution menu
年中大促 | 集成无忧,超值套餐 6 折起
[in depth understanding of tcapulusdb technology] form creation and approval of document acceptance
[deeply understand tcapulusdb technology] create a game area for document acceptance
It supports running in kubernetes, adds multiple connectors, and seatunnel version 2.1.2 is officially released!
跨域 CORS/OPTIONS
播放增长900w,B站用户叫好叫座的恰饭总结