/** * ownCloud - News * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Bernhard Posselt * @copyright Bernhard Posselt 2014 */ app.directive('newsEnclosure', function () { 'use strict'; return { restrict: 'E', scope: { link: '@', type: '@' }, transclude: true, template: '
' + '' + '' + '
' + '
', link: function (scope, elem) { if (scope.type.indexOf('audio') === 0) { scope.mediaType = 'audio'; } else { scope.mediaType = 'video'; } var source = elem.children() .children(scope.mediaType) .children('source')[0]; var cantPlay = false; scope.cantPlay = function () { return cantPlay; }; source.addEventListener('error', function () { scope.$apply(function () { cantPlay = true; }); }); } }; });