duan0818 2019-06-30 08:51
浏览 351
已采纳

如何在PHP中将m3u8转换为base64编码?

I have clapper player andI i add url m3u8 and I need to encoding the url

this is the code:

   <script>
   var player = new Clappr.Player({source: 'http://vstream2.hadara.ps:8081/AlfajertvHD2_web/web1/playlist.m3u8',

parentId: '#player', mimeType: 'application/x-mpegURL',plugins: [DashShakaPlayback,LevelSelector,ChromecastPlugin],levelSelectorConfig: {
title: 'Quality',
labels: {
    2: 'High', // 500kbps
    1: 'Med', // 240kbps
    0: 'Low', // 120kbps
},
labelCallback: function(playbackLevel, customLabel) {
    return customLabel + playbackLevel.level.height+'p'; // High 720p
}
  • 写回答

1条回答 默认 最新

  • drpp5680 2019-06-30 11:21
    关注

    it should work like this:

    <script>
    var player = new Clappr.Player({
        source: window.atob(<?php echo '"' . base64_encode($data['link']) . '"'; ?>),
        parentId: '#player',
        mimeType: 'application/x-mpegURL',
        plugins: [DashShakaPlayback,LevelSelector,ChromecastPlugin],
        levelSelectorConfig: {
            title: 'Quality',
            labels: {
                2: 'High', // 500kbps
                1: 'Med', // 240kbps
                0: 'Low', // 120kbps
            },
            labelCallback: function(playbackLevel, customLabel) {
                return customLabel + playbackLevel.level.height+'p'; // High 720p
            }
        }
    });
    </script>
    

    But I still think, you should look up on the site where you bought the stream from, if they support any kind of encryption. The shaka player plugin which you are using, supports aes encryption, so it should be ok. You will probably need to implement some logic in php to sign the stream url.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改