经过多次播放后,iOS UIWebView中的HTML5视频上的MEDIA_ERR_DECODE [英] MEDIA_ERR_DECODE on HTML5 video in iOS UIWebView after many plays

查看:1715
本文介绍了经过多次播放后,iOS UIWebView中的HTML5视频上的MEDIA_ERR_DECODE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS中的UIWebView中的HTML5视频控件中播放约20个短视频片段(mp4)之后,后续片段失败并显示 MEDIA_ERR_DECODE 。问题是,我知道视频很好,因为它们之前曾播放过,有时甚至在同一个会话期间播放。

After playing around 20 short video clips (mp4's) in an HTML5 video control in a UIWebView in iOS, subsequent clips are failing with a MEDIA_ERR_DECODE. The thing is, is that I know the videos are fine, because they were previously played, sometimes even during the same session.

此外,如果您等待足够长的时间来请求新的视频片段,它通常会再次开始工作。

Furthermore, if you wait long enough to request a new video clip, it will usually start working again.

我也知道它不是服务器,因为我可以在桌面计算机上对chrome执行完全相同的操作,但它始终有效。

I also know it's not the server because I can do the exact same operation on chrome on my desktop computer and it always works.

根据我的故障排除,似乎这个bug本身就是iOS。

Based on my troubleshooting, it seems like the bug is in iOS itself.


  1. 有没有人有任何想法解决这个问题?

  2. 有什么方法可以获得更多iOS中有关媒体解码错误的信息?我尝试使用Safari的开发工具来收听http请求,但我不能让它记录的时间超过几秒钟才会出现内存不足错误并导致应用程序死亡。

更新:在iOS模拟器中运行时也能正常工作。似乎问题只发生在iPad本身上

推荐答案

与Apple支持人员讨论后,问题出在固定。问题与硬件H264解码器有关。基本上,我从不通过永远不释放视频资源(我认为javascript会自己做)来从硬件解码器缓冲区中删除视频。

After a discussion with Apple Support, the problem has been fixed. The problem has to do with the hardware H264 decoder. Basically, I was never removing the videos from the hardware decoder buffer by never releasing the video resources (which I thought javascript would do itself).

所以我设置了这样的来源:

So I was setting the source like this:

$(vid).src = "some source file";
$(vid).play();
... some other stuff happens ...
$(vid).remove();

这样做从来没有从解码器缓冲区中删除视频,这意味着它最终无法通过解码更多视频。

Doing it this way never removed the video from the decoder buffer, which meant that eventually it not be able to decode any more videos.

要解决此问题,您必须从DOM中删除视频:

To fix this, this is how you must remove the video from the DOM:

$(vid).src = "some source file";
$(vid).play();
... some other stuff happens ...
$(vid).remove();
$(vid).src = "";
$(vid).load();

现在我意识到这并没有多大意义,因为在之后调用.remove(),我会假设控件已从DOM中删除,任何垃圾收集都会自动完成剩下的工作。但是,它并不像那样。我希望这有助于其他人。

Now I realize that this doesn't make a ton of sense because after .remove() is called, I would have assumed that the control has been removed from the DOM and any garbage collection would do the rest automatically. However, it doesn't work like that. I hope this helps other people.

这篇关于经过多次播放后,iOS UIWebView中的HTML5视频上的MEDIA_ERR_DECODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆