Pause an embed video

In ionic 1x if you have modal and if it contains a youtube embed video then sometimes when you close the modal video is continue the play.

This method solve the problem.

$scope.pauseVideo = function() {
	if(document.getElementsByTagName("iframe").length > 0){
		var iframe = document.getElementsByTagName("iframe")[0].contentWindow;
		iframe.postMessage('{"event":"command","func":"' + 'pauseVideo' +   '","args":""}', '*');

$scope.$on('$ionicView.beforeLeave', function(){

Posted in "Ionic" Views 4318            Published 09/02/2018

All Comments (0)
No Comments