HTML5视频/音频播放器控件使用AngularJS播放和暂停(HTML5 video/audio player control play & pause with AngularJS)
我想用AngularJS控制HTML5音频/视频播放器。 我想玩和暂停那个玩家。 我可以使用jQuery来做到这一点。 但我需要它与AngularJS合作。
I want to control HTML5 audio/video player with AngularJS. I want to play & pause that player. I can do this using jQuery. But I need it to work with AngularJS.
原文:https://stackoverflow.com/questions/30899331
更新时间:2020-01-24 23:59
最满意答案
创建自己的自定义指令可以为您完成工作(首选和可重用),
最简单的方法是使用angular.element并使用其功能从DOM中选择所需的视频元素。
//控制器function myCtrl($scope) {
$scope.url = "url of video or audio"
$scope.pauseOrPlay = function(ele){
var video = angular.element(ele.srcElement);
video[0].pause(); // video.play()
}
}
creating your own custom directive can does the job for you (Preferred and reusable),