基于阿里云播SDK 制作自己的在线M3U8播放器

前提是搭建好PHP 运行环境

浏览器输入http://域名或者IP/aliplayer.php?url=  后面直接填M3U8连接

还可以直接用在影视网站中,作为播放器使用,我这个就是用在MACCMS的视频网站,这个播放插件有记忆播放功能,蛮不错的。唯一确定是自动下一集功能,需要苹果CMS自动下一集和记忆播放的,可以看看这个 苹果CMS 自动下一集功能和记忆播放的播放器-CSDN博客

1.在 aliplayer.php 中构建播放器的基本框架:

<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="IE=edge" >
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
 <title>M3U8在线播放器</title>
<link rel="stylesheet" href="https://g.alicdn.com/apsara-media-box/imp-web-player/2.25.1/skins/default/aliplayer-min.css" />
<script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/apsara-media-box/imp-web-player/2.25.1/aliplayer-min.js"></script>
<script type="text/javascript" charset="utf-8" src="/aliplayercomponents-1.0.10.min.js"></script>
</head>
<body>
</div> 
<div class="prism-player" id="player-con"></div>
<script>
  var player = new Aliplayer({
  "id": "player-con",
  "source": "<?php echo($_REQUEST['url']);?>",
  "width": "100%",
  "height": "100%",
  "autoplay": true,
  "isLive": false,
  "rePlay": false,
  "playsinline": true,
  "isVBR": true,
  "preload": true,
  "controlBarVisibility": "hover",
  "useH5Prism": true,
  skinLayout:[
   {name: "bigPlayButton", align: "blabs", x: 30, y: 80},
    {name: "H5Loading", align: "cc"},
    {name: "errorDisplay", align: "tlabs", x: 0, y: 0},
    {name: "infoDisplay"},
    {name:"tooltip", align:"blabs",x: 0, y: 56},
    {name: "thumbnail"},
    {name: "controlBar", align: "blabs", x: 0, y: 0,
      children: [
        {name: "progress", align: "blabs", x: 0, y: 44},
        {name: "playButton", align: "tl", x: 15, y: 12},
        {name: "timeDisplay", align: "tl", x: 10, y: 7},
        {name: "fullScreenButton", align: "tr", x: 10, y: 12},
        {name:"setting", align:"tr",x:15, y:12},
      ]
    }
  ],
    components: [{
       name: 'RateComponent',
      type: AliPlayerComponent.RateComponent},/* 倍速播放. */
      {name: "MemoryPlayComponent",
      type: AliPlayerComponent.MemoryPlayComponent,/* 记忆播放 */
    args:[true]
    }],
  },
  function (player) {
$('.prism-play-btn').on('click', function(event) {

	$(".prism-controlbar").toggleClass('bar-open');

});}

);

</script>
</body>

其中第8行 有段JS文件是aliplayer Web播放器SDK组件, 这个组件还在不定时更新,现在1.0.10是最新版本。地址https://github.com/aliyunvideo/AliyunPlayer_Web/blob/master/customComponents/dist/aliplayer-components/aliplayercomponents-1.0.10.min.js下载后放到aliplayer.php一个目录下

通过百度网盘分享的文件:aliplayercomponents-1.0.10.min.js
链接:https://pan.baidu.com/s/14APfqbm5bO9cGbbSOdpKoQ?pwd=alyu 
提取码:alyu

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值