<video id="video-player" ng-click="togglePlayer($event)"
oncontextmenu="return false" autoplay="true" loop
class="composition-video" ng-src="{{url}}" type="video/mp4"></video>
如何在angularjs中控制器中视频播放器状态发生变化时捕获事件?
答案 0 :(得分:0)
这是一种使用指令添加侦听器到视频元素的可能方法:
http://plnkr.co/edit/dOm5TnGiSkJAUAtXSFa1?p=preview
.directive('videoEvents', function () {
return function ($scope, $element) {
$element[0].addEventListener("loadeddata", function () {
console.log('loadeddata');
// you can $rootScope.$broadcast...
});
$element[0].addEventListener("playing", function () {
console.log('playing');
// you can $rootScope.$broadcast...
});
// and so on...
}
});