admin管理员组文章数量:1023838
I'm still trying to understand angular...
Basically, I have an html5 video and I want to listen to the onloadeddata
event (.asp).
This is what I have:
html:
<video autoplay="autoplay" loaded-data loop style="display: none;">
<source src="videos/example.mp4" type="video/mp4">
<source src="videos/example.ogg" type="video/ogg">
</video>
directive:
angular.module('myApp')
.directive('loadedData', function () {
return function ($scope, $element) {
$element.addEventListener("loadeddata", function () {
console.log('test'); // never calls
});
}
});
Is this the correct way of handling this? For some reason, the event listener never gets called.
I've also tried
$element.bind('loadedData', function () {
console.log('test');
});
but it also doesn't work...
I'm still trying to understand angular...
Basically, I have an html5 video and I want to listen to the onloadeddata
event (http://www.w3schools./jsref/event_onloadeddata.asp).
This is what I have:
html:
<video autoplay="autoplay" loaded-data loop style="display: none;">
<source src="videos/example.mp4" type="video/mp4">
<source src="videos/example.ogg" type="video/ogg">
</video>
directive:
angular.module('myApp')
.directive('loadedData', function () {
return function ($scope, $element) {
$element.addEventListener("loadeddata", function () {
console.log('test'); // never calls
});
}
});
Is this the correct way of handling this? For some reason, the event listener never gets called.
I've also tried
$element.bind('loadedData', function () {
console.log('test');
});
but it also doesn't work...
Share Improve this question asked Jan 19, 2015 at 0:37 VicVic 8,9917 gold badges47 silver badges56 bronze badges2 Answers
Reset to default 2Figured it out! Looks like I need to use:
$element[0].addEventListener(...)
Instead of:
$element.addEventListener(...)
$element.on('loadeddata', function (event) {
var width = $element[0].videoWidth;
}
'loadeddata' works for me 'loadedData' does not
I'm still trying to understand angular...
Basically, I have an html5 video and I want to listen to the onloadeddata
event (.asp).
This is what I have:
html:
<video autoplay="autoplay" loaded-data loop style="display: none;">
<source src="videos/example.mp4" type="video/mp4">
<source src="videos/example.ogg" type="video/ogg">
</video>
directive:
angular.module('myApp')
.directive('loadedData', function () {
return function ($scope, $element) {
$element.addEventListener("loadeddata", function () {
console.log('test'); // never calls
});
}
});
Is this the correct way of handling this? For some reason, the event listener never gets called.
I've also tried
$element.bind('loadedData', function () {
console.log('test');
});
but it also doesn't work...
I'm still trying to understand angular...
Basically, I have an html5 video and I want to listen to the onloadeddata
event (http://www.w3schools./jsref/event_onloadeddata.asp).
This is what I have:
html:
<video autoplay="autoplay" loaded-data loop style="display: none;">
<source src="videos/example.mp4" type="video/mp4">
<source src="videos/example.ogg" type="video/ogg">
</video>
directive:
angular.module('myApp')
.directive('loadedData', function () {
return function ($scope, $element) {
$element.addEventListener("loadeddata", function () {
console.log('test'); // never calls
});
}
});
Is this the correct way of handling this? For some reason, the event listener never gets called.
I've also tried
$element.bind('loadedData', function () {
console.log('test');
});
but it also doesn't work...
Share Improve this question asked Jan 19, 2015 at 0:37 VicVic 8,9917 gold badges47 silver badges56 bronze badges2 Answers
Reset to default 2Figured it out! Looks like I need to use:
$element[0].addEventListener(...)
Instead of:
$element.addEventListener(...)
$element.on('loadeddata', function (event) {
var width = $element[0].videoWidth;
}
'loadeddata' works for me 'loadedData' does not
本文标签: javascriptAngular on video load eventStack Overflow
版权声明:本文标题:javascript - Angular on video load event - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745512002a2153868.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论