blob: efcf5dfecba1c98ca98f5bceef1a203604a986f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/**
* ownCloud - News
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.directive('newsAudio', () => {
'use strict';
return {
restrict: 'E',
scope: {
src: '@',
type: '@'
},
transclude: true,
template: '' +
'<audio controls="controls" preload="none" ng-hide="cantPlay()">' +
'<source ng-src="{{ src|trustUrl }}">' +
'</audio>' +
'<a ng-href="{{ src|trustUrl }}" class="button" ng-show="cantPlay()" ' +
'ng-transclude></a>',
link: (scope, elm) => {
let source = elm.children().children('source')[0];
let cantPlay = false;
source.addEventListener('error', () => {
scope.$apply(() => {
cantPlay = true;
});
});
scope.cantPlay = () => {
return cantPlay;
};
}
};
});
|