Sha*_*ngh 2 html5-video angularjs videogular
我正在使用Videogular来显示视频.当用户点击播放按钮到新视频时,你能帮我看看如何停止/暂停其他视频.因此,用户一次只能播放一个视频.
系统应自动停止在后台播放的其他视频并播放新视频
谢谢
您可以为每个玩家单独获取所有API,并监听状态的变化:
<videogular ng-repeat="config in ctrl.videoConfigs" vg-player-ready="ctrl.onPlayerReady($API, $index)" vg-update-state="ctrl.onUpdateState($state, $index)">
<!-- other plugins here -->
</videogular>
Run Code Online (Sandbox Code Playgroud)
在你的控制器:
'use strict';
angular.module('myApp').controller('MainCtrl',
function ($sce) {
// this.videoConfigs should have different configs for each player...
this.players = [];
this.onPlayerReady = function (API, index) {
this.players[index] = API;
};
this.onUpdateState = function (state, index) {
if (state === 'play') {
// pause other players
for (var i=0, l=this.players.length; i<l; i++) {
if (i !== index) {
this.players[i].pause();
}
}
}
};
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2447 次 |
| 最近记录: |