Skip to content

Instantly share code, notes, and snippets.

@diegoaguilar
Created January 31, 2016 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save diegoaguilar/70572c2aaaf5cc161861 to your computer and use it in GitHub Desktop.
Save diegoaguilar/70572c2aaaf5cc161861 to your computer and use it in GitHub Desktop.
angular-binding.js
'use strict';
function link($scope, $elem, $attrs) {
$elem.on('canplay', () => {
this.$timeout(()=> {$scope.$emit('finalcutplayer.events.canplay')});
});
$elem.on('timeupdate', () => {
this.$timeout(()=> {$scope.$emit('finalcutplayer.events.timeupdate', {time: $elem.currentTime})});
});
$elem.on('ended', () => {
this.$timeout(()=> {$scope.$emit('finalcutplayer.events.ended')});
});
$scope.$on('finalcutplayer.communication.updates.video', (event, data) => {
console.log('Yah, I hear voices, so what?');
console.log('They tell me ...');
console.log(JSON.stringify(data));
});
}
global.angular.module('FinalCutApp').directive('finalcutPlayer', function ($timeout) {
return {
restrict: 'A',
link: global.angular.bind(this, link)
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment