使用mediaelement在Android上播放hls

时间:2012-12-05 08:01:21

标签: android streaming mediaelement.js

我正在尝试使用mediaelement.js用户界面在iPad,iPhone和Android上播放hls。

html如下所示(我不能公开我们的hls链接):

<video src="testinghls.m3u8"></video>

脚本:

$('video').mediaelementplayer({
      // if the <video width> is not specified, this is the default
      defaultVideoWidth: 480,
      // if the <video height> is not specified, this is the default
      defaultVideoHeight: 270,
      // specify to force MediaElement to use a particular video or audio type
      type: 'application/x-mpegURL',
      // the order of controls you want on the control bar (and other plugins below)
      features: ['playpause','progress','volume','fullscreen'],
      // Hide controls when playing and mouse is not over the video
      alwaysShowControls: false,
      // force iPad's native controls
      iPadUseNativeControls: false,
      // force iPhone's native controls
      iPhoneUseNativeControls: false,
      // force Android's native controls
      AndroidUseNativeControls: false
    });

在iPad和iPhone上工作正常,但Android无法正常工作。它只是以某种方式检测到视频无法播放并回退到下载链接。

除了我已尝试使用hls的纯视频标签,它在iOS和Android设备中都可以正常使用,如下所示:

<video src="{{c.get('hls')}}" type="application/x-mpegURL" style="width:320px;height:185px" controls></video>
<video src="{{c.get('hls')}}" style="width:320px;height:185px" controls></video>

我应该如何配置Mediaelement以使其正常工作?或者也许用Mediaelement.js进行一些调整/修改?

1 个答案:

答案 0 :(得分:2)

这可能是视频编码问题。 Android需要特定的编码,这是MediaElement.js中的一个着名问题

this

建议采用此解决方案