ampervue / ngJWPlayer

Angular directives to instanciate a jwPlayer
MIT License
12 stars 6 forks source link

ng-jwplayer

Angular Directive to instantiate a JWPlayer. Requires a license and JS package from http://www.jwplayer.com/

Installation

Use bower:

bower install ng-jwplayer --save

or NPM

npm install ng-jwplayer --save

Usage

<script type="text/javascript" src="https://github.com/ampervue/ngJWPlayer/raw/master/bower_components/angular/angular.js"></script>
<!-- Remplace xxxxxxxxx with your license code given by JWPLayer -->
<script src="https://content.jwplatform.com/libraries/xxxxxxxxxxxx.js"></script>    
<script type="text/javascript" src="https://github.com/ampervue/ngJWPlayer/raw/master/bower_components/ng-jwplayer/jwplayer.min.js"></script>
$scope.options = {
   height: 360,
   width: 640,
   advertising: {
    client: "vast",
    tag: "http://adserver.com/vastTag.xml"
   }
}

$scope.file: "http://example.com/myVideo.mp4",
var myApp = angular.module('myApp', ['ng-jwplayer']);
myApp.controller('mainController', ['$scope', '$log', '$sce', function($scope, $log, $sce) {

   $scope.name = 'JWPlayer Example';

   $scope.options = {
        type: 'mp4',
        image: 'http://example.com/myVideoPoster.jpg'
   };

   $scope.file = $sce.trustAsResourceUrl('http://example.com/myVideo.mp4');

   // Optional: Catch ng-jwplayer event for when JWPlayer is ready
   $scope.$on('ng-jwplayer-ready', function(event, args) {

        $log.info('Player' + args.playerId + 'Ready.');
        // Get player from service
        var player = jwplayerService.myPlayer[args.playerId];
   });
]);
<jwplayer ng-src="https://github.com/ampervue/ngJWPlayer/raw/master/{{ file }}"
          player-options="options"
          player-id="myPlayer1">
</jwplayer>
<jwplayer ng-src="https://github.com/ampervue/ngJWPlayer/raw/master/{{ file1 }}"
          player-options="options1"
          player-id="myPlayer1">
</jwplayer>
<jwplayer ng-src="https://github.com/ampervue/ngJWPlayer/raw/master/{{ file2 }}"
          player-options="options2"
          player-id="myPlayer2">
</jwplayer>

Samples

Version Changes

Contribute

To build, use

npm install
bower install
gulp

Inspired by ds62987/angular-jwplayer