停止正在播放的背景上发挥新的其他视频 [英] stop other video that is playing in background on play the new one

查看:162
本文介绍了停止正在播放的背景上发挥新的其他视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Videogular显示视频。你可以请帮我如何停止/暂停等视频时播放按钮,新的用户点击。因此,通过这一次的用户可以在同一时间只能播放一个视频。

I am using Videogular to show video. could you please help me how to stop/pause other video when user click on play button to new one. So by this at a time user can play only one video at a time.

,系统应自动停止在后台播放其他视频和播放新一

The system should automatically stop other video that is playing in background and play the new one

感谢

推荐答案

您可以分别得到所有API为每个玩家也能聆听到状态的改变:

You can get all the APIs separately for each player and listen for a change in the state:

<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>

在你的控制器:

'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();
                    }
                }
            }
        };
    }
);

这篇关于停止正在播放的背景上发挥新的其他视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆