UnKnown UnKnown - 1 month ago 10
jQuery Question

The play() request was interrupted by a new load request

I have a HTML5 video tag for which user can add a video through input type file component .

My question is that on click of the remove link , is it possibe to remove the video ??

I have tried as

$(document).on("click", ".removepic", function(event)
{
$("#somevideo").val('');
var player = document.getElementById("video");
var currentVID = document.getElementById('currentVID');
// currentVID.setAttribute('src', '');
currentVID.setAttribute('src', '');
player.load();
player.play();
});


By doing so i am getting

Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.playlocalVID @ VM79:56onchange @ VM716:91


Steps to reproduce the issue in below fiddle


  1. Upload any mp4 video

  2. Click on Remove link

  3. repeat step 1



In server console i am getting


VM79:56Uncaught (in promise) DOMException: The play() request was
interrupted by a new load request.


This is my fiddle

https://jsfiddle.net/q3hhk17e/30/

Could you please tell me how to fix this issue ??

Answer

Try this and its working. I have updated your fiddle also.

$(document).on("click", ".removepic", function(event)
{
        $("#somevideo").val('');
         var player = document.getElementById("video");
         player.pause();
         var currentVID = document.getElementById('currentVID');
         currentVID.setAttribute('src', '');
        player.load();
       // player.play();
});
Comments