Last active
August 29, 2015 14:17
-
-
Save SuperstrongBE/ed0175dc94b59abb21d8 to your computer and use it in GitHub Desktop.
Angular video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module ('app.media') | |
directive('videoPlayer',function ($sce,$timeout,videoPlayerService){ | |
var linkFn | |
,controllerFn | |
,templateStr | |
; | |
templateStr = '<video ng-src="{{src}}"></video><section ng-transclude></section>' | |
linkFn = function (scope,elm,attrs){ | |
scope.player = elm.find('video')[0]; | |
}; | |
controllerFn = function ($scope){ | |
$scope.src = ''; | |
$scope.controls = { | |
play:function (){ | |
$scope.player.play(); | |
} | |
,stop:function (){ | |
console.log ('stop it'); | |
$scope.player.pause(); | |
} | |
,pause:function (){ | |
console.log ('pause it'); | |
$scope.player.pause(); | |
} | |
}; | |
$scope.source = { | |
setSource:function(src){ | |
$scope.src = src; | |
} | |
} | |
videoPlayerService.subscribe($scope) | |
}; | |
return { | |
link:linkFn | |
,controller:controllerFn | |
,template:templateStr | |
,restrict:'E' | |
,transclude:true | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module ('app.media',[]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module ('app.Media') | |
.service ('videoPlayerService',function (){ | |
var subscribeFn | |
,unsubscribeFn | |
,videoPlayers | |
,clearAllFn | |
,getVideoPlayerFn | |
,getVideoPlayersFn | |
; | |
videoPlayers = []; | |
subscribeFn = function (playerScope){ | |
videoPlayers.push (playerScope); | |
}; | |
unsubscribeFn = function (playerScope){ | |
//todo implement unsubscribe | |
}; | |
getVideoPlayerFn = function (playerScope){ | |
//todo implement loop that search for player | |
return videoPlayers[0]; | |
}; | |
getVideoPlayersFn = function (){ | |
return videoPlayers; | |
}; | |
clearAllFn = function (){ | |
return videoPlayers=[]; | |
}; | |
return { | |
subscribe:subscribeFn | |
,unsubscribe:unsubscribeFn | |
,clearAll:clearAllFn | |
,getPlayer:getVideoPlayerFn | |
,getPlayers:getVideoPlayersFn | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment