Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

561
Visualizações
Why am I receiving an uncaught error in a play function despite having a play promise in the code?

I was originally received the following error in a code for a video player: Uncaught (in promise) DOMException: The fetching process for the media resource was aborted by the user agent at the user's request, so I looked up a solution and came across this article. I then replaced all the play and pause functions with the fix detailed in the article but it didn't solve the error. Did I implement the fix improperly? Any guidance would be much appreciated, thanks!

    function pauseVideo( idx, div, img, playPromise )
    {
        img = getVideoElm( idx, div, img );
        if( !img )
            return;
        else
      var playPromise = img.play();
      if (playPromise !== undefined) {
    playPromise.then(_ => {
        if( img.paused )
                    addClass( img, 'video-paused');
                else
                    removeClass( img, 'video-paused');
                    img.pause();
    })
    .catch(error => {
      console.log("playPromise is undefined");
    });
  }
    else
      console.log("Video failed to pause");
    }
    function resumeVideo( idx, div, img, forcePause, playPromise )
    {
        img = getVideoElm( idx, div, img );
    var playPromise = img.play();
        if( !img )
            return;
        else if( forcePause || hasClass(img, 'video-paused') )
            img.pause();
    else if (playPromise !== undefined) {
    playPromise.then(_ => {
    })
    .catch(error => {
      console.log("playPromise is undefined");
    });
  }
        else
            console.log("Video failed to load");
    
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda