"use strict";
angular.module('com.2fdevs.videogular', []).directive('vgPlayer',
[function () {
return {
restrict: 'E',
template: '<video ng-click="ctrl.playPause()" controls>'+
'<source ng-repeat="video in sources" src="{{video.src}}" type="{{video.type}}">'+
'</video>',
scope: {sources: '='},
controllerAs: 'ctrl',
controller: ['$scope', function($scope) {
this.isPlaying = false;
this.playPause = function playPause() {
if (this.isPlaying) {
$scope.video[0].pause();
}
else {
$scope.video[0].play();
}
this.isPlaying = !this.isPlaying;
};
}],
link: function (scope, elem, attr) {
scope.video = elem.find("video");
}
}
}]
);
import {Component, Template, For, NgElement} from 'angular2/angular2';
@Component({
selector: 'vg-player',
properties: {
'src': 'src'
}
})
@View({
templateUrl: 'scripts/com/2fdevs/videogular/core/vg-player.html',
directives: [For]
})
export class VideogularPlayer {
src:String;
isPlaying:Boolean = false;
element:HTMLElement;
constructor(elem:NgElement) {
this.element = elem.domElement;
}
playPause() {
this.isPlaying = !this.isPlaying;
if (this.isPlaying) this.element.play();
else this.element.pause();
}
}
<video ng-click="ctrl.playPause()" controls>
<!-- more shit -->
</video>
<video (click)="playPause()" controls>
<!-- more shit -->
</video>
<video ng-click="ctrl.playPause()" controls>
<source ng-repeat="video in sources" src="{{video.src}}" type="{{video.type}}">
</video>
<video (click)="playPause()" controls>
<source template="for #video of src" [src]="video.src" [type]="video.type">
</video>
<head>
<link href="styles/vg-player.css">
</head>
<!-- more shit -->
<video ng-click="ctrl.playPause()" controls>
<source ng-repeat="video in sources" src="{{video.src}}" type="{{video.type}}">
</video>
<style>@import 'styles/videogular.css';</style>
<video (click)="playPause()" controls>
<source template="for #video of src" [src]="video.src" [type]="video.type">
</video>