在离子中播放HLS流

时间:2016-10-06 18:38:06

标签: javascript android angularjs html5

我正在尝试在离子angularjs中播放HLS流,我将hls流放入iframe中,如下所示:

<iframe ng-src="http://barakyah-channel.videocdn.scaleengine.net/barakyah-channel/live/hottestjamsaudio/playlist.m3u8" seamless="seamless" scrolling="no" frameBorder="0" width="100%" height="100%" ></iframe>

我在网上看过这个方法。

而不是播放它要求我下载播放列表由于某种原因它不起作用。

我也尝试过使用viblast的HTML5音频播放器:

<audio id="player" src="http://barakyah-channel.videocdn.scaleengine.net/barakyah-channel/live/hottestjamsaudio/playlist.m3u8" data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" controls></audio>

我尝试了另一个解决方案:

<button class="button" ng-click="play('http://barakyah-channel.videocdn.scaleengine.net/barakyah-channel/live/hottestjamsaudio/playlist.m3u8')">Play from file system</button>

这个解决方案的JS:

 $scope.play = function(src) {
        var media = new Media(src, null, null, mediaStatusCallback);
        media.play(media);
    }

    var mediaStatusCallback = function(status) {
        if(status == 1) {
            $ionicLoading.show({template: 'Loading...'});
        } else {
            $ionicLoading.hide();
        }
    }

这些都没有奏效。 我也在Android设备上进行了测试,但仍然没有用。

我没有错误它只是不播放它要求我下载一些播放列表的东西(它拉出一个保存框的地方)

请帮忙 谢谢

1 个答案:

答案 0 :(得分:0)

您的MIME类型是application / vnd.apple.mpegurl,由wget输出

$ wget http://barakyah-channel.videocdn.scaleengine.net/barakyah-channel/live/hottestjamsaudio/playlist.m3u8
--2017-04-10 11:06:25--  http://barakyah-channel.videocdn.scaleengine.net/barakyah-channel/live/hottestjamsaudio/playlist.m3u8
Resolving barakyah-channel.videocdn.scaleengine.net... 173.208.17.141
Connecting to barakyah-channel.videocdn.scaleengine.net|173.208.17.141|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 107 [application/vnd.apple.mpegurl]
Saving to: ‘playlist.m3u8.1’

playlist.m3u8     100%[===================>]     107  --.-KB/s    in 0s      

2017-04-10 11:06:27 (6.38 MB/s) - ‘playlist.m3u8’ saved [107/107]

尝试将其更改为server- / cdn-side:

application/x-mpegurl m3u8;
video/mp2t ts;
application/xml xml;