简体   繁体   English

Android Chrome:未捕获(承诺)DOMException:由于找不到受支持的源而无法加载

[英]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属性,则会发现以下内容:

  • Properly loaded videos have the value set to 4 HAVE_ENOUGH_DATA 正确加载的视频的值设置为4 HAVE_ENOUGH_DATA
  • Videos that didn't load properly have their value set to 1 HAVE_METADATA 未正确加载的视频的值设置为1 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: 我正在研究的下一个解决方案:

  1. Download the blob 下载Blob
  2. Set the video.src and call video.load() 设置video.src并调用video.load()
  3. Wait for the 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.

相关问题 Chrome:未捕获(承诺)DOMException:无法加载,因为找不到支持的源 - Chrome: Uncaught (in promise) DOMException: Failed to load because no supported source was found 在 Vue 中播放声音 onClick 事件返回 Uncaught (in promise) DOMException: Failed to load because no supported source was found - playing sound onClick event in Vue returns Uncaught (in promise) DOMException: Failed to load because no supported source was found 播放带有特殊字符的音频时,“(未承诺)DOMException:未能加载,因为找不到支持的源” - “Uncaught (in promise) DOMException: Failed to load because no supported source was found” when playing an audio with special characters DOMException:加载失败,因为未找到支持的源 - DOMException: Failed to load because no supported source was found 无法加载音频 - DOMException:无法加载,因为找不到支持的源 - Cant load Audio - DOMException: Failed to load because no supported source was found 加载失败,因为找不到支持的源 - Failed to load because no supported source was found Android:URL.createObjectURL无法正常工作(由于找不到受支持的源而无法加载。) - Android: URL.createObjectURL does not work properly (Failed to load because no supported source was found.) Phonegap视频“由于找不到支持的来源而无法加载” - Phonegap Video “Failed to load because no supported source was found” 如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有首先与文档交互。” 在桌面上使用 Chrome 66? - How to handle "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." on Desktop with Chrome 66? 如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有先与文档交互。”? - How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM