简体   繁体   English

HLS Stream Android 4.4.2 Samsung Galaxy S5上没有视频

[英]No Video on HLS Stream Android 4.4.2 Samsung Galaxy S5

The HLS streams do not play video, but they do play audio. HLS流不会播放视频,但是会播放音频。

Device information: 设备信息:

Samsung Galaxy S5 三星Galaxy S5

Android 4.4.2 / Build KOT49H Android 4.4.2 / Build KOT49H

Chrome 36.0.1985.131 铬36.0.1985.131

HLS Streams that play on other Android builds and devices: 在其他Android版本和设备上播放的HLS流:

Using the browser application "Internet" on the Samsung S5, it will play the video for an HLS stream, which made me think this could possibly be an issue with Chrome, however, when tested on a Nexus 5 device with the exact same Chrome build (except Android 4.4.4) and the video plays fine. 使用三星S5上的浏览器应用程序“ Internet”,它将播放HLS流的视频,这使我认为Chrome可能是一个问题,但是,当在具有完全相同的Chrome版本的Nexus 5设备上进行测试时(Android 4.4.4除外),并且视频可以正常播放。

Android Issue Queue has Issue 63810: No video in HLS live streaming on Android KitKat and I have contributed what I can. Android Issue Queue的问题为63810:HLS上没有视频在Android KitKat上进行实时流传输 ,我已尽力而为

What can I do to get more information about the nature of the problem? 我该怎么做才能获得有关问题性质的更多信息?

Is this a legitimate bug with the Android 4.4.2 Samsung S5? 这是Android 4.4.2 Samsung S5的合法错误吗?

I've noticed this behavior among other issues on 4.4.2 with issues seeming to vary by device and manufacturer. 我注意到此行为在4.4.2的其他问题中,其问题似乎因设备和制造商而异。 Through experimentation I've noticed the following: 通过实验,我注意到了以下几点:

  1. Entering or exiting full screen seems to reset the renderer. 进入退出全屏似乎重置了渲染器。 I suspect this forces the browser to create a new View or something 我怀疑这会迫使浏览器创建新的视图或其他内容
  2. Reloading the video seems to help the renderer 重新加载视频似乎对渲染器有所帮助
  3. Changing sources seems to make things worse 改变来源似乎会使情况更糟

Our product works essentially on a playlist -- when the ended event triggers for one video we change the video src and call .load() and .play() to go to the next one. 我们的产品主要适用于播放列表-当ended事件的一个视频触发我们改变了视频src和调用.load().play()去下一个。 On some devices if the first src is HLS video plays fine, but if the first src is mp4 or webm then switching to HLS causes you to lose video. 在某些设备上,如果第一个src是HLS,则视频可以正常播放,但是如果第一个src是mp4或webm,则切换到HLS会使您丢失视频。 On other devices it's the opposite behavior -- starting in HLS fails but switching to it succeeds. 在其他设备上,这是相反的行为-在HLS中启动失败,但切换成功。 On some devices HLS has video if you enter full screen before it starts to play, on others it only has video if you enter full screen after it starts to play. 在某些设备上,如果你进入全屏开始播放之前,对别人,如果你进入全屏开始播放后,它不仅具有视频HLS具有视频。 On some devices the full screen button disappears after you start to play. 在某些设备上,开始播放后,全屏按钮消失

It's not ideal and it's honestly very hacky, but I've come up with this ugly solution: 这不是理想的,而且老实说很hacky,但是我想出了一个丑陋的解决方案:

// 1.
video.addEventListener('click', requestFullScreen);
// 2.
function requestFullScreen() {
    video.removeEventListener('click', requestFullScreen);
    video.webkitRequestFullScreen();
}
// 3.
function reloadVideo() {
    var ext = video.src.substr( video.src.lastIndexOf('.') ).toLowerCase();
    if( ext == '.m3u8' ) {
        video.load();
        video.play();
    }
}
// 4.
video.addEventListener('webkitbeginfullscreen', reloadVideo, false);
video.addEventListener('webkitendfullscreen', reloadVideo, false);
// 5.
video.addEventListener('webkitfullscreenchange', reloadVideo, false);
  1. This is to fix the "full screen button disappears after you start playing on some devices" bug 这是修复“在某些设备上开始播放后全屏按钮消失的错误”的错误
  2. We give this function a name so we can remove it later. 我们给该函数起一个名字,以便以后删除。 If they request to exit fullscreen then they will not blame your player if the full screen button disappears. 如果他们要求退出全屏播放,那么如果全屏显示按钮消失,他们将不会怪罪您的播放器。 At this point they'll blame the phone and they'll refresh the page. 此时,他们将责备手机,并刷新页面。 This way people don't get pissed off if they accidentally fullscreen it again while trying to scroll 这样,如果人们在尝试滚动时再次意外全屏显示,便不会生气
  3. A helper function. 辅助功能。 We don't want to restart videos when going fullscreen unless we have to 全屏播放时,我们不想重启视频,除非我们必须
  4. The stock Internet browser throws these two events 股票的Internet浏览器引发这两个事件
  5. Chrome throws this event Chrome引发此事件

There are a number of other hacks I've had to implement, as well. 我还必须实现许多其他技巧。 For instance, the stock Internet browser on the Galaxy S4 does not always throw an ended event when reaching the end of a video. 例如,当到达视频结尾时,Galaxy S4上的常规Internet浏览器并不总是引发ended事件。 For this reason I have a setInterval checking every 1 second. 因此,我每隔1秒进行一次setInterval检查。 If the video has moved less than 0.5 seconds in the last 1 seconds and it was never paused (I have a flag that's set in the resume and pause events) then assume you've hit the end. 如果视频在过去1秒钟内移动的时间少于0.5秒钟, 并且从未暂停过(我在“ resume和“ pause事件中设置了一个标志),则假定您已经结束了。

I've had success using preload="none" . 我已经成功使用preload="none" Switching to auto will only play audio, using none will play both video and audio properly. 切换到auto只能播放音频,使用none将播放视频和音频正常。 This was tested on a Samsung S3, Android 4.4.2. 已在Samsung S3 Android 4.4.2上进行了测试。

EDIT: autoplay also contributes to the problem. 编辑: autoplay也会导致该问题。 Removing it appears necessary. 删除它似乎很有必要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM