简体   繁体   English

如何修复“Uncaught(in promise)DOMException:play()”

[英]how to fix “Uncaught (in promise) DOMException: play() ”

I am trying to autoplay video background in html5,css,angular5- Randomly its working and not working. 我试图在html5,css,angular5-自动播放视频背景 - 随机工作,不工作。

So I tried to include code in angular that to play when it is loading the page.It's throwing -Uncaught (in promise) DOMException: play() 所以我尝试在加载页面时将角色包含在角色中。它正在抛出-Uncaught(在promise中)DOMException:play()

I tried checked stackoverflow same error like this.I have applied those solution in multiple way to fix the issue. 我试过像这样检查stackoverflow相同的错误。我已经以多种方式应用这些解决方案来解决问题。 Still throwing error. 仍在抛出错误。

    component
    =========
    @ViewChild('videoPlay') videoplay: ElementRef;
    videopl: HTMLVideoElement;

    //first i tried this. Still throwing error
    this.videoplay.nativeElement.play();

    //second i tried this still throwing error.
    const playPromise = this.videoplay.nativeElement.play();
    if (playPromise !== null){
     playPromise.catch(() => { this.videoplay.nativeElement.play(); })
    }

    //third i tried this still throwing error.
    this.videopl=this.videoplayer.nativeElement;
    this.videopl.play();


    html part
    =========
    <!--first try-->
    <video id="videoid" autoplay muted loop  preload
     poster="img.png"  #videoPlayer>
    <source src="video.mp4" type='video/mp4' >
    <source src="video.webm" type="video/webm">
    <source src="video.ogg" type="video/ogg">
    </video>

     <!--second try-->
     <video id="videoid" autoplay="true" muted="muted" loop  preload 
       poster="img.png"  #videoPlayer>
    <source src="video.mp4" type='video/mp4' >
    <source src="video.webm" type="video/webm">
    <source src="video.ogg" type="video/ogg">
    </video>


    <!--third try-->
    <video id="videoid" autoplay="autoplay" muted="muted" loop  preload
     poster="img.png"  #videoPlayer>
    <source src="video.mp4" type='video/mp4' >
    <source src="video.webm" type="video/webm">
    <source src="video.ogg" type="video/ogg">
    </video>

Need to play video automatically without any error. 需要自动播放视频而不会出现任何错误。

This solution worked for me to autoplay is here=> https://stackoverflow.com/a/52980364/5755872 这个解决方案适合我自动播放在这里=> https://stackoverflow.com/a/52980364/5755872

 <video id="videoid" autoplay muted loop  preload
 poster="img.png"  oncanplay="this.play()" onloadedmetadata="this.muted = true">
 <source src="video.mp4" type='video/mp4' >
<source src="video.webm" type="video/webm">
<source src="video.ogg" type="video/ogg">
</video>

Only I need is to autoplay my video.so I am removed all the lines in component for play function. 我只需要自动播放我的视频。所以我删除了组件中的所有线路以便播放功能。

“Uncaught (in promise) DOMException: play() ”-this issue i didn't find any solutions. “未捕获(承诺)DOMException:play()” - 这个问题我找不到任何解决方案。 But i will try to find the solution for this error also. 但我也会尝试找到这个错误的解决方案。

Thank you for reading this issue. 感谢您阅读此问题。

暂无
暂无

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

相关问题 如何处理Uncaught(在promise中)DOMException:play()请求被pause()调用中断 - How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() video.play()获取(承诺)DOMException - video.play() get Uncaught (in promise) DOMException 如何在ajax调用中避免Uncaught(in promise)DOMException? - How to avoid Uncaught (in promise) DOMException on ajax call? 如何解决Uncaught(in promise)DOMException错误? - How to solve Uncaught (in promise) DOMException error? 如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有先与文档交互。”? - How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.”? 如何防止错误“未捕获(承诺)DOMException:播放()请求被暂停()调用中断。”? - How do I prevent the error "Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()."? IndexedDB:未捕获(承诺)DOMException - IndexedDB: Uncaught (in promise) DOMException 未捕获(在Promise中)DOMException:play()只能由用户手势启动 - Uncaught (in Promise) DOMException: play() can only be initiated by a user gesture 视频错误 - 未捕获(承诺)DOMException:调用 pause() 中断了 play() 请求 - Video error - Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() 如何处理“未捕获(承诺)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?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM