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 onl
While the answer from elecash is a fine answer, there is a lot of guessing and storage. I choose to store only the active api on the $rootScope and paused the other player when a new player has started.
controller('VideoPlayerCtrl', ['$rootScope','$scope', function($rootScope,$scope) {
$scope.playerReady = function(api) {
$scope.api = api;
};
$scope.stateChange = function(state) {
if(state=='play') {
if($rootScope.playingVideo && $rootScope.playingVideo != $scope.api) $rootScope.playingVideo.pause();
$rootScope.playingVideo = $scope.api;
}
};
}]);