From 7f5c67cb18f150eb3ba1f6d4abbd53ba91c639c6 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 11 Feb 2015 23:42:00 +0300 Subject: [PATCH] Added unsupported media for Safari OPUS is not supported there yet --- app/js/directives.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 3a06769e..1d227353 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -2441,8 +2441,8 @@ angular.module('myApp.directives', ['myApp.filters']) downloadPromise.then(function () { onContentLoaded(function () { - var audioEl = $('audio', element)[0]; - if (audioEl) { + var errorListenerEl = $('audio', element)[0] || element[0]; + if (errorListenerEl) { var errorAlready = false; var onAudioError = function (event) { if (errorAlready) { @@ -2462,16 +2462,18 @@ angular.module('myApp.directives', ['myApp.filters']) } }; - audioEl.addEventListener('error', onAudioError, true); - $(audioEl).on('$destroy', function () { + errorListenerEl.addEventListener('error', onAudioError, true); + $scope.$on('$destroy', function () { errorAlready = true; - audioEl.removeEventListener('error', onAudioError); + errorListenerEl.removeEventListener('error', onAudioError); }); } - checkPlayer($scope.mediaPlayer.player); - $scope.mediaPlayer.player.setVolume(audioVolume); - $scope.mediaPlayer.player.play(); - }) + setTimeout(function () { + checkPlayer($scope.mediaPlayer.player); + $scope.mediaPlayer.player.setVolume(audioVolume); + $scope.mediaPlayer.player.play(); + }, 300); + }); }) } };