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

如何在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.

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

报告相同问题?