I need to tell, whether video cannot be played (\"x\" sign is shown in browser).
This code does\'t works. \"onerror\" event will never be fired under Firefox
From Firefox 4 onwards, the 'error' event is dispatched on the
And you should add an error handler on the only/last source:
var v = document.querySelector('video#vid');
var sources = v.querySelectorAll('source');
if (sources.length !== 0) {
var lastSource = sources[sources.length-1];
lastSource.addEventListener('error', function() {
alert('uh oh');
});
}
$('video source').last().on('error', function() {
alert('uh oh');
});
You can create an error handling directive (or just use ng-error):
Where the error handling directive's link function should do (copied from ng-error):
element.on('error', function(event) {
scope.$apply(function() {
fn(scope, {$event:event});
});
});