当前位置:网站首页>让知识付费系统视频支持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
边栏推荐
- 芯和半导体“射频EDA/滤波器设计平台”闪耀IMS2022
- [in depth understanding of tcapulusdb technology] introduction tcapulusdb problem summary
- 【深入理解TcaplusDB技术】单据受理之建表审批
- Random talk on redis source code 119
- 运用span-method巧妙实现多层table数据的行合并
- 跨域 CORS/OPTIONS
- leetcode.11 --- 盛最多水的容器
- CVPR 2022 oral | video text pre training new SOTA, HKU and Tencent arc lab launched excuse task based on multiple-choice questions
- [deeply understand tcapulusdb technology] how to start tcapulusdb process
- Please describe the whole process from entering a URL in the browser to rendering the page.
猜你喜欢

软件上线前为什么要做性能测试?软件性能测试机构怎么找

Introduction of neural networks for Intelligent Computing (Hopfield network DHNN, CHNN)

Using span method to realize row merging of multi-layer table data
![[resolved] -go_ out: protoc-gen-go: Plugin failed with status code 1.](/img/da/9ced1c0a9c386bc8da75dddaa443e5.png)
[resolved] -go_ out: protoc-gen-go: Plugin failed with status code 1.

Easydss problem and solution summary

他98年的,我玩不过他...

EasyDSS问题及解决方案汇总

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

One picture decoding opencloudos community open day
![[proteus simulation] 74LS138 decoder water lamp](/img/30/7dbdead9c18788cd946b5541e76443.png)
[proteus simulation] 74LS138 decoder water lamp
随机推荐
[in depth understanding of tcapulusdb technology] getting started with MySQL driver
510000 prize pool invites you to join the war! The second Alibaba cloud ECS cloudbuild developer competition is coming
IDEA写jsp代码报错,但是正常运行解决
3个月自学自动化测试,薪资从4.5K到15K,鬼知道我经历了什么?
web技术分享| 【高德地图】实现自定义的轨迹回放
Possible security vulnerabilities in NFT
Teach you how to create SSM project structure in idea
Random talk on redis source code 119
[deeply understand tcapulusdb technology] tcapulusdb table management - delete table
Unityeditor editor script execution menu
client-go gin的简单整合十一-Delete
市场开始降温,对NFT 是坏事么?
Introduction of neural network (BP) in Intelligent Computing
Merge sort (recursive and iterative Implementation)
[in depth understanding of tcapulusdb technology] business guide for creating doc acceptance
【深入理解TcaplusDB技术】单据受理之创建业务指南
[deeply understand tcapulusdb technology] realize tcapulusdb transaction management in the operation and maintenance platform
Recv function with timeout
ZABBIX learning notes (37)
Random talk about redis source code onehundredandtwenty