-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As that is what bower install needs
- Loading branch information
David Karchmer
committed
Sep 12, 2015
1 parent
7239ac2
commit 4483bda
Showing
5 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ bower_components/ | |
.sass-cache/ | ||
.idea/ | ||
.tmp/ | ||
dist/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ng-jwplayer", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "dist/jwplayer.js", | ||
"ignore": [ | ||
"src", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/** | ||
* Created by David Karchmer on 9/11/15. | ||
*/ | ||
(function() { | ||
'use strict'; | ||
|
||
angular | ||
.module('ng-jwplayer', [ | ||
]); | ||
})(); | ||
/* global jwplayer */ | ||
/** | ||
* Created by David Karchmer on 9/11/15. | ||
*/ | ||
|
||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('ng-jwplayer') | ||
.service('jwplayerService', JWPlayerService); | ||
|
||
/* @ngInject */ | ||
function JWPlayerService($log) { | ||
|
||
this.existJWPlayer = function() { | ||
return (angular.isDefined(this.myPlayer) && this.myPlayer !== null); | ||
}; | ||
|
||
this.initJWPlayer = function(id) { | ||
|
||
if (this.existJWPlayer()) { | ||
|
||
$log.debug('Instance of JWPlayer exists. Removing first'); | ||
this.myPlayer.remove(); | ||
this.myPlayer = null; | ||
} | ||
|
||
this.myPlayer = jwplayer(id); | ||
|
||
return this.myPlayer; | ||
}; | ||
|
||
this.cleanUp = function() { | ||
if (this.existJWPlayer()) { | ||
|
||
$log.debug('Removing existing JWPlayer'); | ||
this.myPlayer.remove(); | ||
this.myPlayer = null; | ||
} | ||
}; | ||
} | ||
JWPlayerService.$inject = ["$log"]; | ||
|
||
})(); | ||
/** | ||
* Created by David Karchmer on 9/11/15. | ||
*/ | ||
(function() { | ||
'use strict'; | ||
|
||
angular | ||
.module('ng-jwplayer') | ||
.directive('jwplayer', JWPlayer); | ||
|
||
/* @ngInject */ | ||
function JWPlayer($compile, $log, jwplayerService) { | ||
|
||
var player; | ||
|
||
var _renderJWPlayerElement = function(scope, element) { | ||
var id = scope.playerId, | ||
getTemplate = function (playerId) { | ||
return '<div id="' + playerId + '"></div>'; | ||
}; | ||
|
||
element.html(getTemplate(id)); | ||
$compile(element.contents())(scope); | ||
player = jwplayerService.initJWPlayer(id); | ||
player.setup(scope.playerOptions); | ||
}; | ||
|
||
return { | ||
restrict: 'EC', | ||
scope: { | ||
playerId: '@', | ||
playerOptions: '=' | ||
}, | ||
link: function (scope, element, attrs) { | ||
|
||
scope.$on('$destroy', function () { | ||
$log.debug('jwplayer onDestroy'); | ||
jwplayerService.cleanUp(); | ||
}); | ||
|
||
scope.$watch(function () { | ||
return attrs.ngSrc; | ||
}, function (value) { | ||
$log.debug('ng-src has changed: ' + value); | ||
if (angular.isDefined(scope.playerOptions)) { | ||
scope.playerOptions.file = value; | ||
_renderJWPlayerElement(scope, element); | ||
} | ||
}); | ||
|
||
if (angular.isDefined(attrs.ngSrc) && angular.isDefined(scope.playerOptions)) { | ||
scope.playerOptions.file = attrs.ngSrc; | ||
_renderJWPlayerElement(scope, element); | ||
} | ||
} | ||
}; | ||
} | ||
JWPlayer.$inject = ["$compile", "$log", "jwplayerService"]; | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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