[英]Android Chrome : Uncaught (in promise) DOMException: Failed to load because no supported source was found
I am working on a web application in Javascript playing several mp4 videos in a row. 我正在使用Javascript开发Web应用程序,连续播放多个mp4视频。 Everything works fine but on Android using Chrome.
一切正常,但可在使用Chrome的Android上运行。 The first three videos are playing fine but from the fourth when I call video.play() method I get this error in the console : "Uncaught (in promise) DOMException: Failed to load because no supported source was found."
前三个视频播放正常,但是从第四个视频调用video.play()方法时,我在控制台中收到此错误:“未捕获(承诺)DOMException:由于找不到支持的源而无法加载。”
I am sure that all the video sources (blob) are correct because I can load them all in another tab. 我确信所有视频源(blob)都是正确的,因为我可以将它们全部加载到另一个选项卡中。
I am generating my video element like this : 我正在生成这样的视频元素:
generate_video_element = function(src) {
var v = document.createElement('video');
v.src = src
v.type = "video/mp4";
return v;
};
I get this error on Android (Chrome only) when I call : 致电时,我在Android(仅限Chrome)上收到此错误:
v.play();
It returns me a promise which is pending forever... Thanks in advance for your help. 它给了我一个永远待定的承诺……在此先感谢您的帮助。
The most likely cause of that error, given the information you provide, is that the particular MP4 file is not supported on the Android device you are using. 根据您提供的信息,最可能导致该错误的原因是,您使用的Android设备不支持特定的MP4文件。
MP4 is a 'container' specification for video and audio steams and the videos and audios in the container may use different encodings, so some mp4 files may be supported and others may not on a given device or player. MP4是视频和音频流的“容器”规范,并且容器中的视频和音频可能使用不同的编码,因此,某些mp4文件可能受支持,而其他文件可能不在给定的设备或播放器上。
This answer gives an example of debugging this using tools like ffprobe and looking in particular the the 'profile' (essentially a pre-defined set of options available within the encoding) of the h.264 encoding which is often an issue on mobile devices: https://stackoverflow.com/a/47478676/334402 该答案给出了一个使用ffprobe之类的工具进行调试并特别查看h.264编码的“配置文件”(本质上是编码中可用的预定义选项集)的示例,该问题通常在移动设备上会出现: https://stackoverflow.com/a/47478676/334402
There's the following issue on Chrome on Android: Android上的Chrome浏览器存在以下问题:
Calling video.load()
on multiple video's at the same time causes some of the loads to hang. video.load()
在多个视频上调用video.load()
会导致某些负载挂起。
If you then inspect the video.readyState
property, you will find the following: 如果然后检查
video.readyState
属性,则会发现以下内容:
HAVE_ENOUGH_DATA
HAVE_ENOUGH_DATA
HAVE_METADATA
HAVE_METADATA
I'm not sure where exactly the load
method is being called in your case (source change, or when calling play
, or maybe it's just not being called at all), but you should probably try to have videos be loaded one after another and not in parallel. 我不确定在您的情况下到底在何处调用
load
方法(源更改,或在调用play
,或者根本就没有被调用),但是您可能应该尝试逐个加载视频,然后不平行。
The next solution I'm investigating: 我正在研究的下一个解决方案:
video.src
and call video.load()
video.src
并调用video.load()
video.oncanplaythrough
event to start loading the next one video.oncanplaythrough
事件开始加载下一个 Hopefully, this should avoid the issue while still working on other browsers. 希望这可以在仍然使用其他浏览器的情况下避免该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.