satish kumar V
satish kumar V

Reputation: 1755

JavaScript - The play() request was interrupted by a call to pause()

I made a website where if the user clicks, it should plays a video. and clicking on same should pause,

whenever I tried to pause it is showing

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().

here is my plnkr

Can someone assist me?

I tried

setTimeout(function () {  
var item = $(".myVideosClick")[0];          
  if (!item.paused) {
    item.pause();
  }
}, 100);

but it is not working for me.

Upvotes: 0

Views: 247

Answers (1)

Ihor Korotenko
Ihor Korotenko

Reputation: 906

Instead of setTimeout use $timeout service which is the Angular wrapper for setTimeout and it uses $scope.$apply inside. Also, instead of using JQuery for click event binding use ng-click directive. Example:

$scope.videoClickHandler = function(){
    //do on click logic
}

Also you can try to make bigger timeout, 300 works well in my case.

Upvotes: 1

Related Questions