|
|
@ -1822,7 +1822,7 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
.directive('myAudioPlayer', function ($sce, $timeout, MtpApiFileManager) { |
|
|
|
.directive('myAudioPlayer', function ($sce, $timeout, $q, FileManager, MtpApiFileManager) { |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
link: link, |
|
|
|
link: link, |
|
|
@ -1847,6 +1847,7 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
|
|
|
|
|
|
|
|
return downloadPromise.then(function (url) { |
|
|
|
return downloadPromise.then(function (url) { |
|
|
|
delete audio.progress; |
|
|
|
delete audio.progress; |
|
|
|
|
|
|
|
audio.rawUrl = url; |
|
|
|
audio.url = $sce.trustAsResourceUrl(url); |
|
|
|
audio.url = $sce.trustAsResourceUrl(url); |
|
|
|
}, function (e) { |
|
|
|
}, function (e) { |
|
|
|
console.log('audio download failed', e); |
|
|
|
console.log('audio download failed', e); |
|
|
@ -1861,6 +1862,14 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
function link($scope, element, attrs) { |
|
|
|
function link($scope, element, attrs) { |
|
|
|
$scope.mediaPlayer = {}; |
|
|
|
$scope.mediaPlayer = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.download = function () { |
|
|
|
|
|
|
|
($scope.audio.rawUrl ? $q.when() : downloadAudio($scope.audio)).then( |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
FileManager.download($scope.audio.rawUrl, $scope.audio.mime_type || 'audio/ogg', $scope.audio.file_name || 'audio.ogg'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.togglePlay = function () { |
|
|
|
$scope.togglePlay = function () { |
|
|
|
if ($scope.audio.url) { |
|
|
|
if ($scope.audio.url) { |
|
|
|
$scope.mediaPlayer.player.playPause(); |
|
|
|
$scope.mediaPlayer.player.playPause(); |
|
|
@ -1870,15 +1879,11 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
downloadAudio($scope.audio).then(function () { |
|
|
|
downloadAudio($scope.audio).then(function () { |
|
|
|
$timeout(function () { |
|
|
|
onContentLoaded(function () { |
|
|
|
var audioElement = $('audio', element)[0]; |
|
|
|
$scope.mediaPlayer.player.play(); |
|
|
|
if (audioElement) { |
|
|
|
}) |
|
|
|
audioElement.autoplay = false; |
|
|
|
|
|
|
|
audioElement.removeAttribute('autoplay'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 1000); |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|