summaryrefslogtreecommitdiff
path: root/www/lib/videogular
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2016-06-26 18:08:07 -0400
committerPliable Pixels <pliablepixels@gmail.com>2016-06-26 18:08:07 -0400
commita1f3994a1849dbd1b5157adf8c16e6e72ca5736e (patch)
treeeac5c64796a12a0dc9ee8bc495eb6805e345064c /www/lib/videogular
parent4c63b323d7fa20f9ed8494c627235c5f2892ff85 (diff)
updated videogular to 1.4.4
Former-commit-id: 7348ef0ae60746ce86cd4e813cf10e8b53e723d7
Diffstat (limited to 'www/lib/videogular')
-rw-r--r--www/lib/videogular/.bower.json15
-rw-r--r--www/lib/videogular/bower.json2
-rw-r--r--www/lib/videogular/index.js2
-rw-r--r--www/lib/videogular/package.json6
-rw-r--r--www/lib/videogular/videogular.js242
-rw-r--r--www/lib/videogular/videogular.min.js2
6 files changed, 198 insertions, 71 deletions
diff --git a/www/lib/videogular/.bower.json b/www/lib/videogular/.bower.json
index f105cfd7..2246d623 100644
--- a/www/lib/videogular/.bower.json
+++ b/www/lib/videogular/.bower.json
@@ -1,20 +1,19 @@
{
"name": "videogular",
- "version": "1.3.2",
+ "version": "1.4.4",
"main": "./videogular.js",
"dependencies": {
"angular": "^1.3.x",
"angular-sanitize": "^1.3.x"
},
"homepage": "https://github.com/2fdevs/bower-videogular",
- "_release": "1.3.2",
+ "_release": "1.4.4",
"_resolution": {
"type": "version",
- "tag": "v1.3.2",
- "commit": "b0c01c91bd5277797d3a02e5546a5b31423cfeaa"
+ "tag": "v1.4.4",
+ "commit": "6075385b6f0e41ffa707cf2c1f0afd456ac45e69"
},
- "_source": "git://github.com/2fdevs/bower-videogular.git",
- "_target": "~1.3.2",
- "_originalSource": "videogular",
- "_direct": true
+ "_source": "https://github.com/2fdevs/bower-videogular.git",
+ "_target": "~1.4.4",
+ "_originalSource": "videogular"
} \ No newline at end of file
diff --git a/www/lib/videogular/bower.json b/www/lib/videogular/bower.json
index c593e6c9..50cca3b7 100644
--- a/www/lib/videogular/bower.json
+++ b/www/lib/videogular/bower.json
@@ -1,6 +1,6 @@
{
"name": "videogular",
- "version": "1.3.2",
+ "version": "1.4.4",
"main": "./videogular.js",
"dependencies": {
"angular": "^1.3.x",
diff --git a/www/lib/videogular/index.js b/www/lib/videogular/index.js
index 51945645..84d99a76 100644
--- a/www/lib/videogular/index.js
+++ b/www/lib/videogular/index.js
@@ -1,4 +1,4 @@
-require('angular');
+require('angular');
require('angular-sanitize');
require('./videogular');
diff --git a/www/lib/videogular/package.json b/www/lib/videogular/package.json
index ee4603b7..9892ee30 100644
--- a/www/lib/videogular/package.json
+++ b/www/lib/videogular/package.json
@@ -1,7 +1,11 @@
{
"name": "videogular",
- "version": "1.3.2",
+ "version": "1.4.4",
"main": "index.js",
+ "dependencies": {
+ "angular": "^1.3.0",
+ "angular-sanitize": "^1.3.0"
+ },
"devDependencies": {
"grunt": "~0.4.1",
"grunt-release": "~0.7.0"
diff --git a/www/lib/videogular/videogular.js b/www/lib/videogular/videogular.js
index 5685b076..1a29b398 100644
--- a/www/lib/videogular/videogular.js
+++ b/www/lib/videogular/videogular.js
@@ -1,5 +1,5 @@
/**
- * @license videogular v1.3.2 http://videogular.com
+ * @license videogular v1.4.4 http://videogular.com
* Two Fucking Developers http://twofuckingdevelopers.com
* License: MIT
*/
@@ -78,13 +78,13 @@ angular.module("com.2fdevs.videogular")
* - stop(): Stops media.
* - playPause(): Toggles play and pause.
* - seekTime(value, byPercent): Seeks to a specified time position. Param value must be an integer representing the target position in seconds or a percentage. By default seekTime seeks by seconds, if you want to seek by percentage just pass byPercent to true.
- * - setVolume(volume): Sets volume. Param volume must be an integer with a value between 0 and 1.
- * - setPlayback(playback): Sets playback. Param plaback must be an integer with a value between 0 and 2.
+ * - setVolume(volume): Sets volume. Param volume must be a float number with a value between 0 and 1.
+ * - setPlayback(playback): Sets playback. Param plaback must be a float number with a value between 0 and 2.
* - setState(state): Sets a new state. Param state mus be an string with 'play', 'pause' or 'stop'. This method only changes the state of the player, but doesn't plays, pauses or stops the media file.
* - toggleFullScreen(): Toggles between fullscreen and normal mode.
* - updateTheme(css-url): Removes previous CSS theme and sets a new one.
* - clearMedia(): Cleans the current media file.
- * - changeSource(array): Updates current media source. Param `array` must be an array of media source objects.
+ * - changeSource(array): Updates current media source. Param `array` must be an array of media source objects or a simple URL string.
* A media source is an object with two properties `src` and `type`. The `src` property must contains a trustful url resource.
* <pre>{src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.mp4"), type: "video/mp4"}</pre>
*
@@ -98,7 +98,7 @@ angular.module("com.2fdevs.videogular")
* - nativeFullscreen: Boolean value to know if Videogular if fullscreen mode will use native mode or emulated mode.
* - mediaElement: Reference to video/audio object.
* - videogularElement: Reference to videogular tag.
- * - sources: Array with current sources.
+ * - sources: Array with current sources or a simple URL string.
* - tracks: Array with current tracks.
* - cuePoints: Object containing a list of timelines with cue points. Each property in the object represents a timeline, which is an Array of objects with the next definition:
* <pre>{
@@ -139,12 +139,28 @@ angular.module("com.2fdevs.videogular")
var currentTheme = null;
var isFullScreenPressed = false;
var isMetaDataLoaded = false;
+ var hasStartTimePlayed = false;
+ var isVirtualClip = false;
// PUBLIC $API
this.videogularElement = null;
this.clearMedia = function () {
this.mediaElement[0].src = '';
+ this.mediaElement[0].removeEventListener("canplay", this.onCanPlay.bind(this), false);
+ this.mediaElement[0].removeEventListener("loadedmetadata", this.onLoadMetaData.bind(this), false);
+ this.mediaElement[0].removeEventListener("waiting", this.onStartBuffering.bind(this), false);
+ this.mediaElement[0].removeEventListener("ended", this.onComplete.bind(this), false);
+ this.mediaElement[0].removeEventListener("playing", this.onStartPlaying.bind(this), false);
+ this.mediaElement[0].removeEventListener("play", this.onPlay.bind(this), false);
+ this.mediaElement[0].removeEventListener("pause", this.onPause.bind(this), false);
+ this.mediaElement[0].removeEventListener("volumechange", this.onVolumeChange.bind(this), false);
+ this.mediaElement[0].removeEventListener("playbackchange", this.onPlaybackChange.bind(this), false);
+ this.mediaElement[0].removeEventListener("timeupdate", this.onUpdateTime.bind(this), false);
+ this.mediaElement[0].removeEventListener("progress", this.onProgress.bind(this), false);
+ this.mediaElement[0].removeEventListener("seeking", this.onSeeking.bind(this), false);
+ this.mediaElement[0].removeEventListener("seeked", this.onSeeked.bind(this), false);
+ this.mediaElement[0].removeEventListener("error", this.onVideoError.bind(this), false);
};
this.onRouteChange = function() {
@@ -155,7 +171,12 @@ angular.module("com.2fdevs.videogular")
this.onCanPlay = function (evt) {
this.isBuffering = false;
- $scope.$apply($scope.vgCanPlay({$event: evt}));
+ $scope.$parent.$digest($scope.vgCanPlay({$event: evt}));
+
+ if (!hasStartTimePlayed && (this.startTime > 0 || this.startTime === 0)) {
+ this.seekTime(this.startTime);
+ hasStartTimePlayed = true;
+ }
};
this.onVideoReady = function () {
@@ -164,10 +185,13 @@ angular.module("com.2fdevs.videogular")
this.playsInline = $scope.vgPlaysInline;
this.nativeFullscreen = $scope.vgNativeFullscreen || true;
this.cuePoints = $scope.vgCuePoints;
+ this.startTime = $scope.vgStartTime;
+ this.virtualClipDuration = $scope.vgVirtualClipDuration;
this.clearMediaOnNavigate = $scope.vgClearMediaOnNavigate || true;
this.currentState = VG_STATES.STOP;
isMetaDataLoaded = true;
+ isVirtualClip = this.startTime >= 0 && this.virtualClipDuration > 0;
//Set media volume from localStorage if available
if (VG_UTILS.supportsLocalStorage()) {
@@ -194,6 +218,9 @@ angular.module("com.2fdevs.videogular")
$scope.vgNativeFullscreen = this.config.nativeFullscreen;
$scope.vgCuePoints = this.config.cuePoints;
$scope.vgClearMediaOnNavigate = this.config.clearMediaOnNavigate;
+ $scope.vgStartTime = this.config.startTime;
+ $scope.vgVirtualClipDuration = this.config.virtualClipDuration;
+ isVirtualClip = $scope.vgStartTime >= 0 && $scope.vgVirtualClipDuration > 0;
$scope.vgPlayerReady({$API: this});
};
@@ -204,39 +231,65 @@ angular.module("com.2fdevs.videogular")
};
this.onProgress = function (event) {
+ this.updateBuffer(event);
+
+ $scope.$parent.$digest();
+ };
+
+ this.updateBuffer = function getBuffer(event) {
if (event.target.buffered.length) {
this.buffered = event.target.buffered;
this.bufferEnd = 1000 * event.target.buffered.end(event.target.buffered.length - 1);
- }
- $scope.$apply();
+ // Avoid bufferEnd overflow by virtual clips
+ if (this.bufferEnd > this.totalTime) this.bufferEnd = this.totalTime;
+ }
};
this.onUpdateTime = function (event) {
- this.currentTime = 1000 * event.target.currentTime;
+ var targetTime = 1000 * event.target.currentTime;
- if (event.target.buffered.length) {
- this.buffered = event.target.buffered;
- this.bufferEnd = 1000 * event.target.buffered.end(event.target.buffered.length - 1);
- }
+ this.updateBuffer(event);
+
+ if (event.target.duration != Infinity && event.target.duration != null && event.target.duration != undefined && event.target.duration != 1.7976931348623157e+308) {
+ // Fake the duration and current time for virtual clips
+ if (isVirtualClip) {
+ if (hasStartTimePlayed && (event.target.currentTime < this.startTime || event.target.currentTime - this.startTime > this.virtualClipDuration)) {
+ this.onComplete();
+ }
+ else {
+ this.currentTime = Math.max(0, targetTime - (1000 * this.startTime));
+ this.totalTime = 1000 * this.virtualClipDuration;
+ this.timeLeft = (1000 * this.virtualClipDuration) - this.currentTime;
+ }
+ }
+ else {
+ this.currentTime = targetTime;
+ this.totalTime = 1000 * event.target.duration;
+ this.timeLeft = 1000 * (event.target.duration - event.target.currentTime);
+ }
- if (event.target.duration != Infinity) {
- this.totalTime = 1000 * event.target.duration;
- this.timeLeft = 1000 * (event.target.duration - event.target.currentTime);
this.isLive = false;
}
else {
// It's a live streaming without and end
+ this.currentTime = targetTime;
this.isLive = true;
}
+ var targetSeconds = isVirtualClip ? this.currentTime / 1000 : event.target.currentTime;
+ var targetDuration = isVirtualClip ? this.totalTime / 1000 : event.target.duration;
+
if (this.cuePoints) {
- this.checkCuePoints(event.target.currentTime);
+ this.checkCuePoints(targetSeconds);
}
- $scope.vgUpdateTime({$currentTime: event.target.currentTime, $duration: event.target.duration});
+ $scope.vgUpdateTime({$currentTime: targetSeconds, $duration: targetDuration});
- $scope.$apply();
+ // Safe apply just in case we're calling from a non-event
+ if ($scope.$$phase != '$apply' && $scope.$$phase != '$digest') {
+ $scope.$parent.$digest();
+ }
};
this.checkCuePoints = function checkCuePoints(currentTime) {
@@ -293,28 +346,30 @@ angular.module("com.2fdevs.videogular")
this.onPlay = function () {
this.setState(VG_STATES.PLAY);
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onPause = function () {
- if (this.mediaElement[0].currentTime == 0) {
+ var currentTime = isVirtualClip ? this.currentTime : this.mediaElement[0].currentTime;
+
+ if (currentTime == 0) {
this.setState(VG_STATES.STOP);
}
else {
this.setState(VG_STATES.PAUSE);
}
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onVolumeChange = function () {
this.volume = this.mediaElement[0].volume;
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onPlaybackChange = function () {
this.playback = this.mediaElement[0].playbackRate;
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onSeeking = function (event) {
@@ -328,12 +383,26 @@ angular.module("com.2fdevs.videogular")
this.seekTime = function (value, byPercent) {
var second;
if (byPercent) {
- second = value * this.mediaElement[0].duration / 100;
- this.mediaElement[0].currentTime = second;
+ if (isVirtualClip) {
+ value = Math.max(0, Math.min(value, 100));
+ second = (value * this.virtualClipDuration / 100);
+ this.mediaElement[0].currentTime = this.startTime + second;
+ }
+ else {
+ second = value * this.mediaElement[0].duration / 100;
+ this.mediaElement[0].currentTime = second;
+ }
}
else {
- second = value;
- this.mediaElement[0].currentTime = second;
+ if (isVirtualClip) {
+ var durationPercent = value/this.mediaElement[0].duration;
+ second = !hasStartTimePlayed ? 0 : this.virtualClipDuration * durationPercent;
+ this.mediaElement[0].currentTime = !hasStartTimePlayed ? this.startTime : this.startTime + second;
+ }
+ else {
+ second = value;
+ this.mediaElement[0].currentTime = second;
+ }
}
this.currentTime = 1000 * second;
@@ -371,9 +440,11 @@ angular.module("com.2fdevs.videogular")
this.stop = function () {
try {
this.mediaElement[0].pause();
- this.mediaElement[0].currentTime = 0;
- this.currentTime = 0;
+ var targetTime = isVirtualClip ? this.startTime : 0;
+ this.mediaElement[0].currentTime = targetTime;
+
+ this.currentTime = targetTime;
this.buffered = [];
this.bufferEnd = 0;
this.setState(VG_STATES.STOP);
@@ -494,12 +565,12 @@ angular.module("com.2fdevs.videogular")
this.onStartBuffering = function (event) {
this.isBuffering = true;
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onStartPlaying = function (event) {
this.isBuffering = false;
- $scope.$apply();
+ $scope.$parent.$digest();
};
this.onComplete = function (event) {
@@ -507,7 +578,12 @@ angular.module("com.2fdevs.videogular")
this.setState(VG_STATES.STOP);
this.isCompleted = true;
- $scope.$apply();
+
+ if (isVirtualClip) {
+ this.stop()
+ }
+
+ $scope.$parent.$digest();
};
this.onVideoError = function (event) {
@@ -543,6 +619,7 @@ angular.module("com.2fdevs.videogular")
this.isFullScreen = false;
this.playback = 1;
this.isConfig = ($scope.vgConfig != undefined);
+ this.mediaElement = [{play:function(){}, pause:function(){}, stop:function(){}, addEventListener:function(){}, removeEventListener: function(){}}];
if (vgFullscreen.isAvailable) {
this.isFullScreen = vgFullscreen.isFullScreen();
@@ -567,6 +644,31 @@ angular.module("com.2fdevs.videogular")
}
};
+ this.onUpdateStartTime = function onUpdateStartTime(newValue) {
+ if (newValue && (newValue != this.startTime)) {
+ this.mediaElement[0].currentTime = newValue;
+ this.startTime = newValue;
+ isVirtualClip = this.startTime >= 0 && this.virtualClipDuration > 0;
+
+ var fakeEvent = {
+ target: this.mediaElement[0]
+ };
+ this.onUpdateTime(fakeEvent, true);
+ }
+ };
+
+ this.onUpdateVirtualClipDuration = function onUpdateVirtualClipDuration(newValue) {
+ if (newValue && (newValue != this.virtualClipDuration)) {
+ this.virtualClipDuration = newValue;
+ isVirtualClip = this.startTime >= 0 && this.virtualClipDuration > 0;
+
+ var fakeEvent = {
+ target: this.mediaElement[0]
+ };
+ this.onUpdateTime(fakeEvent, true);
+ }
+ };
+
this.onUpdatePlaysInline = function onUpdatePlaysInline(newValue) {
this.playsInline = newValue;
};
@@ -591,6 +693,10 @@ angular.module("com.2fdevs.videogular")
$scope.$watch("vgAutoPlay", this.onUpdateAutoPlay.bind(this));
+ $scope.$watch("vgStartTime", this.onUpdateStartTime.bind(this));
+
+ $scope.$watch("vgVirtualClipDuration", this.onUpdateVirtualClipDuration.bind(this));
+
$scope.$watch("vgPlaysInline", this.onUpdatePlaysInline.bind(this));
$scope.$watch("vgNativeFullscreen", this.onUpdateNativeFullscreen.bind(this));
@@ -602,7 +708,7 @@ angular.module("com.2fdevs.videogular")
this.onFullScreenChange = function (event) {
this.isFullScreen = vgFullscreen.isFullScreen();
- $scope.$apply();
+ $scope.$parent.$digest();
};
// Empty mediaElement on destroy to avoid that Chrome downloads video even when it's not present
@@ -738,7 +844,7 @@ angular.module("com.2fdevs.videogular")
* @description
* Directive to add a source of videos or audios. This directive will create a &lt;video&gt; or &lt;audio&gt; tag and usually will be above plugin tags.
*
- * @param {array} vgSrc Bindable array with a list of media sources. A media source is an object with two properties `src` and `type`. The `src` property must contains a trustful url resource.
+ * @param {array} vgSrc Bindable array with a list of media sources or a simple url string. A media source is an object with two properties `src` and `type`. The `src` property must contains a trustful url resource.
* @param {string} vgType String with "video" or "audio" values to set a <video> or <audio> tag inside <vg-media>.
* <pre>
* {
@@ -789,36 +895,42 @@ angular.module("com.2fdevs.videogular")
};
scope.changeSource = function changeSource() {
- var canPlay = "";
-
- // It's a cool browser
- if (API.mediaElement[0].canPlayType) {
- for (var i = 0, l = sources.length; i < l; i++) {
- canPlay = API.mediaElement[0].canPlayType(sources[i].type);
-
- if (canPlay == "maybe" || canPlay == "probably") {
- API.mediaElement.attr("src", sources[i].src);
- API.mediaElement.attr("type", sources[i].type);
- //Trigger vgChangeSource($source) API callback in vgController
- API.changeSource(sources[i]);
- break;
+
+ if (angular.isArray(sources)) {
+ var canPlay = "";
+
+ // It's a cool browser
+ if (API.mediaElement[0].canPlayType) {
+ for (var i = 0, l = sources.length; i < l; i++) {
+ canPlay = API.mediaElement[0].canPlayType(sources[i].type);
+
+ if (canPlay == "maybe" || canPlay == "probably") {
+ API.mediaElement.attr("src", sources[i].src);
+ API.mediaElement.attr("type", sources[i].type);
+ //Trigger vgChangeSource($source) API callback in vgController
+ API.changeSource(sources[i]);
+ break;
+ }
}
}
- }
- // It's a crappy browser and it doesn't deserve any respect
- else {
- // Get H264 or the first one
- API.mediaElement.attr("src", sources[0].src);
- API.mediaElement.attr("type", sources[0].type);
+ // It's a crappy browser and it doesn't deserve any respect
+ else {
+ // Get H264 or the first one
+ API.mediaElement.attr("src", sources[0].src);
+ API.mediaElement.attr("type", sources[0].type);
+ //Trigger vgChangeSource($source) API callback in vgController
+ API.changeSource(sources[0]);
+ }
+ } else {
+ API.mediaElement.attr("src", sources);
//Trigger vgChangeSource($source) API callback in vgController
- API.changeSource(sources[0]);
+ API.changeSource(sources);
}
-
// Android 2.3 support: https://github.com/2fdevs/videogular/issues/187
if (VG_UTILS.isMobileDevice()) API.mediaElement[0].load();
$timeout(function () {
- if (API.autoPlay && !VG_UTILS.isMobileDevice()) {
+ if (API.autoPlay && (VG_UTILS.isCordova() || !VG_UTILS.isMobileDevice())) {
API.play();
}
});
@@ -1126,6 +1238,10 @@ angular.module("com.2fdevs.videogular")
*
* **This parameter is disabled in mobile devices** because user must click on content to prevent consuming mobile data plans.
*
+ * @param {boolean} [vgStartTime=-1] vgStartTime Number value or a String with a scope name variable to start playing the video at a certain time.
+ *
+ * @param {boolean} [vgVirtualClipDuration=-1] vgVirtualClipDuration Number value or a String with a scope name variable for a length to limit the video playback to.
+ *
* @param {object} vgCuePoints Bindable object containing a list of timelines with cue points objects. A timeline is an array of objects with the following properties:
* - `timeLapse` is an object with two properties `start` and `end` representing in seconds the period for this cue points.
* - `onEnter` callback called when user enters on a cue point. callback(currentTime, timeLapse, params)
@@ -1140,6 +1256,8 @@ angular.module("com.2fdevs.videogular")
"controls": false,
"loop": false,
"autoplay": false,
+ "startTime": -1,
+ "virtualClipDuration": -1,
"preload": "auto",
"theme": "path/to/videogular.css",
"sources": [
@@ -1222,6 +1340,8 @@ angular.module("com.2fdevs.videogular")
scope: {
vgTheme: "=?",
vgAutoPlay: "=?",
+ vgStartTime: "=?",
+ vgVirtualClipDuration: "=?",
vgPlaysInline: "=?",
vgNativeFullscreen: "=?",
vgClearMediaOnNavigate: "=?",
@@ -1451,7 +1571,11 @@ angular.module("com.2fdevs.videogular")
};
this.isiOSDevice = function () {
- return (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i));
+ return (navigator.userAgent.match(/ip(hone|ad|od)/i) && !navigator.userAgent.match(/(iemobile)[\/\s]?([\w\.]*)/i));
+ };
+
+ this.isCordova = function () {
+ return document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1;
};
/**
@@ -1460,9 +1584,9 @@ angular.module("com.2fdevs.videogular")
*/
this.supportsLocalStorage = function () {
var testKey = 'videogular-test-key';
- var storage = $window.sessionStorage;
try {
+ var storage = $window.sessionStorage;
storage.setItem(testKey, '1');
storage.removeItem(testKey);
return 'localStorage' in $window && $window['localStorage'] !== null;
diff --git a/www/lib/videogular/videogular.min.js b/www/lib/videogular/videogular.min.js
index 977e6c0b..9c42a625 100644
--- a/www/lib/videogular/videogular.min.js
+++ b/www/lib/videogular/videogular.min.js
@@ -1 +1 @@
-"use strict";angular.module("com.2fdevs.videogular",["ngSanitize"]).run(["$templateCache",function(a){a.put("vg-templates/vg-media-video","<video></video>"),a.put("vg-templates/vg-media-audio","<audio></audio>"),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e})}]),angular.module("com.2fdevs.videogular").constant("VG_STATES",{PLAY:"play",PAUSE:"pause",STOP:"stop"}).constant("VG_VOLUME_KEY","videogularVolume"),angular.module("com.2fdevs.videogular").controller("vgController",["$scope","$window","vgConfigLoader","vgFullscreen","VG_UTILS","VG_STATES","VG_VOLUME_KEY",function(a,b,c,d,e,f,g){var h=null,i=!1,j=!1;this.videogularElement=null,this.clearMedia=function(){this.mediaElement[0].src=""},this.onRouteChange=function(){(void 0===this.clearMediaOnNavigate||this.clearMediaOnNavigate===!0)&&this.clearMedia()},this.onCanPlay=function(b){this.isBuffering=!1,a.$apply(a.vgCanPlay({$event:b}))},this.onVideoReady=function(){this.isReady=!0,this.autoPlay=a.vgAutoPlay,this.playsInline=a.vgPlaysInline,this.nativeFullscreen=a.vgNativeFullscreen||!0,this.cuePoints=a.vgCuePoints,this.clearMediaOnNavigate=a.vgClearMediaOnNavigate||!0,this.currentState=f.STOP,j=!0,e.supportsLocalStorage()&&this.setVolume(parseFloat(b.localStorage.getItem(g)||"1")),a.vgConfig?c.loadConfig(a.vgConfig).then(this.onLoadConfig.bind(this)):a.vgPlayerReady({$API:this})},this.onLoadConfig=function(b){this.config=b,a.vgTheme=this.config.theme,a.vgAutoPlay=this.config.autoPlay,a.vgPlaysInline=this.config.playsInline,a.vgNativeFullscreen=this.config.nativeFullscreen,a.vgCuePoints=this.config.cuePoints,a.vgClearMediaOnNavigate=this.config.clearMediaOnNavigate,a.vgPlayerReady({$API:this})},this.onLoadMetaData=function(a){this.isBuffering=!1,this.onUpdateTime(a)},this.onProgress=function(b){b.target.buffered.length&&(this.buffered=b.target.buffered,this.bufferEnd=1e3*b.target.buffered.end(b.target.buffered.length-1)),a.$apply()},this.onUpdateTime=function(b){this.currentTime=1e3*b.target.currentTime,b.target.buffered.length&&(this.buffered=b.target.buffered,this.bufferEnd=1e3*b.target.buffered.end(b.target.buffered.length-1)),b.target.duration!=1/0?(this.totalTime=1e3*b.target.duration,this.timeLeft=1e3*(b.target.duration-b.target.currentTime),this.isLive=!1):this.isLive=!0,this.cuePoints&&this.checkCuePoints(b.target.currentTime),a.vgUpdateTime({$currentTime:b.target.currentTime,$duration:b.target.duration}),a.$apply()},this.checkCuePoints=function(a){for(var b in this.cuePoints)for(var c=0,d=this.cuePoints[b].length;d>c;c++){var e=this.cuePoints[b][c],f=parseInt(a,10),g=parseInt(e.timeLapse.start,10);e.timeLapse.end||(e.timeLapse.end=e.timeLapse.start+1),a<e.timeLapse.end&&(e.$$isCompleted=!1),e.$$isDirty||f!==g||"function"!=typeof e.onEnter||(e.onEnter(a,e.timeLapse,e.params),e.$$isDirty=!0),a>e.timeLapse.start?(a<e.timeLapse.end&&(e.onUpdate&&e.onUpdate(a,e.timeLapse,e.params),e.$$isDirty||"function"!=typeof e.onEnter||e.onEnter(a,e.timeLapse,e.params)),a>=e.timeLapse.end&&e.onComplete&&!e.$$isCompleted&&(e.$$isCompleted=!0,e.onComplete(a,e.timeLapse,e.params)),e.$$isDirty=!0):(e.onLeave&&e.$$isDirty&&e.onLeave(a,e.timeLapse,e.params),e.$$isDirty=!1)}},this.onPlay=function(){this.setState(f.PLAY),a.$apply()},this.onPause=function(){0==this.mediaElement[0].currentTime?this.setState(f.STOP):this.setState(f.PAUSE),a.$apply()},this.onVolumeChange=function(){this.volume=this.mediaElement[0].volume,a.$apply()},this.onPlaybackChange=function(){this.playback=this.mediaElement[0].playbackRate,a.$apply()},this.onSeeking=function(b){a.vgSeeking({$currentTime:b.target.currentTime,$duration:b.target.duration})},this.onSeeked=function(b){a.vgSeeked({$currentTime:b.target.currentTime,$duration:b.target.duration})},this.seekTime=function(a,b){var c;b?(c=a*this.mediaElement[0].duration/100,this.mediaElement[0].currentTime=c):(c=a,this.mediaElement[0].currentTime=c),this.currentTime=1e3*c},this.playPause=function(){this.mediaElement[0].paused?this.play():this.pause()},this.setState=function(b){return b&&b!=this.currentState&&(a.vgUpdateState({$state:b}),this.currentState=b),this.currentState},this.play=function(){this.mediaElement[0].play(),this.setState(f.PLAY)},this.pause=function(){this.mediaElement[0].pause(),this.setState(f.PAUSE)},this.stop=function(){try{this.mediaElement[0].pause(),this.mediaElement[0].currentTime=0,this.currentTime=0,this.buffered=[],this.bufferEnd=0,this.setState(f.STOP)}catch(a){return a}},this.toggleFullScreen=function(){d.isAvailable&&this.nativeFullscreen?this.isFullScreen?e.isMobileDevice()||d.exit():e.isMobileDevice()?e.isiOSDevice()?j?this.enterElementInFullScreen(this.mediaElement[0]):(i=!0,this.play()):this.enterElementInFullScreen(this.mediaElement[0]):this.enterElementInFullScreen(this.videogularElement[0]):(this.isFullScreen?(this.videogularElement.removeClass("fullscreen"),this.videogularElement.css("z-index","auto")):(this.videogularElement.addClass("fullscreen"),this.videogularElement.css("z-index",e.getZIndex())),this.isFullScreen=!this.isFullScreen)},this.enterElementInFullScreen=function(a){d.request(a)},this.changeSource=function(b){a.vgChangeSource({$source:b})},this.setVolume=function(c){c=Math.max(Math.min(c,1),0),a.vgUpdateVolume({$volume:c}),this.mediaElement[0].volume=c,this.volume=c,e.supportsLocalStorage()&&b.localStorage.setItem(g,c.toString())},this.setPlayback=function(b){a.vgUpdatePlayback({$playBack:b}),this.mediaElement[0].playbackRate=b,this.playback=b},this.updateTheme=function(a){var b,c,d=document.getElementsByTagName("link");if(h)for(b=0,c=d.length;c>b;b++)if(d[b].outerHTML.indexOf(h)>=0){d[b].parentNode.removeChild(d[b]);break}if(a){var e=angular.element(document).find("head"),f=!1;for(b=0,c=d.length;c>b&&!(f=d[b].outerHTML.indexOf(a)>=0);b++);f||e.append("<link rel='stylesheet' href='"+a+"'>"),h=a}},this.onStartBuffering=function(b){this.isBuffering=!0,a.$apply()},this.onStartPlaying=function(b){this.isBuffering=!1,a.$apply()},this.onComplete=function(b){a.vgComplete(),this.setState(f.STOP),this.isCompleted=!0,a.$apply()},this.onVideoError=function(b){a.vgError({$event:b})},this.addListeners=function(){this.mediaElement[0].addEventListener("canplay",this.onCanPlay.bind(this),!1),this.mediaElement[0].addEventListener("loadedmetadata",this.onLoadMetaData.bind(this),!1),this.mediaElement[0].addEventListener("waiting",this.onStartBuffering.bind(this),!1),this.mediaElement[0].addEventListener("ended",this.onComplete.bind(this),!1),this.mediaElement[0].addEventListener("playing",this.onStartPlaying.bind(this),!1),this.mediaElement[0].addEventListener("play",this.onPlay.bind(this),!1),this.mediaElement[0].addEventListener("pause",this.onPause.bind(this),!1),this.mediaElement[0].addEventListener("volumechange",this.onVolumeChange.bind(this),!1),this.mediaElement[0].addEventListener("playbackchange",this.onPlaybackChange.bind(this),!1),this.mediaElement[0].addEventListener("timeupdate",this.onUpdateTime.bind(this),!1),this.mediaElement[0].addEventListener("progress",this.onProgress.bind(this),!1),this.mediaElement[0].addEventListener("seeking",this.onSeeking.bind(this),!1),this.mediaElement[0].addEventListener("seeked",this.onSeeked.bind(this),!1),this.mediaElement[0].addEventListener("error",this.onVideoError.bind(this),!1)},this.init=function(){this.isReady=!1,this.isCompleted=!1,this.buffered=[],this.bufferEnd=0,this.currentTime=0,this.totalTime=0,this.timeLeft=0,this.isLive=!1,this.isFullScreen=!1,this.playback=1,this.isConfig=void 0!=a.vgConfig,d.isAvailable&&(this.isFullScreen=d.isFullScreen()),this.updateTheme(a.vgTheme),this.addBindings(),d.isAvailable&&document.addEventListener(d.onchange,this.onFullScreenChange.bind(this))},this.onUpdateTheme=function(a){this.updateTheme(a)},this.onUpdateAutoPlay=function(a){a&&!this.autoPlay&&(this.autoPlay=a,this.play(this))},this.onUpdatePlaysInline=function(a){this.playsInline=a},this.onUpdateNativeFullscreen=function(a){void 0==a&&(a=!0),this.nativeFullscreen=a},this.onUpdateCuePoints=function(a){this.cuePoints=a,this.checkCuePoints(this.currentTime)},this.onUpdateClearMediaOnNavigate=function(a){this.clearMediaOnNavigate=a},this.addBindings=function(){a.$watch("vgTheme",this.onUpdateTheme.bind(this)),a.$watch("vgAutoPlay",this.onUpdateAutoPlay.bind(this)),a.$watch("vgPlaysInline",this.onUpdatePlaysInline.bind(this)),a.$watch("vgNativeFullscreen",this.onUpdateNativeFullscreen.bind(this)),a.$watch("vgCuePoints",this.onUpdateCuePoints.bind(this)),a.$watch("vgClearMediaOnNavigate",this.onUpdateClearMediaOnNavigate.bind(this))},this.onFullScreenChange=function(b){this.isFullScreen=d.isFullScreen(),a.$apply()},a.$on("$destroy",this.clearMedia.bind(this)),a.$on("$routeChangeStart",this.onRouteChange.bind(this)),this.init()}]),angular.module("com.2fdevs.videogular").directive("vgCrossorigin",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setCrossorigin=function(a){a?d.mediaElement.attr("crossorigin",a):d.mediaElement.removeAttr("crossorigin")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setCrossorigin(d.config.crossorigin)}):a.$watch(c.vgCrossorigin,function(b,c){e&&b==c||!b?a.setCrossorigin():(e=b,a.setCrossorigin(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgLoop",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setLoop=function(a){a?d.mediaElement.attr("loop",a):d.mediaElement.removeAttr("loop")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setLoop(d.config.loop)}):a.$watch(c.vgLoop,function(b,c){e&&b==c||!b?a.setLoop():(e=b,a.setLoop(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgMedia",["$timeout","VG_UTILS","VG_STATES",function(a,b,c){return{restrict:"E",require:"^videogular",templateUrl:function(a,b){var c=b.vgType||"video";return b.vgTemplate||"vg-templates/vg-media-"+c},scope:{vgSrc:"=?",vgType:"=?"},link:function(d,e,f,g){var h;f.vgType&&"video"!==f.vgType?f.vgType="audio":f.vgType="video",d.onChangeSource=function(a,b){h&&a==b||!a||(h=a,g.currentState!==c.PLAY&&(g.currentState=c.STOP),g.sources=h,d.changeSource())},d.changeSource=function(){var c="";if(g.mediaElement[0].canPlayType){for(var d=0,e=h.length;e>d;d++)if(c=g.mediaElement[0].canPlayType(h[d].type),"maybe"==c||"probably"==c){g.mediaElement.attr("src",h[d].src),g.mediaElement.attr("type",h[d].type),g.changeSource(h[d]);break}}else g.mediaElement.attr("src",h[0].src),g.mediaElement.attr("type",h[0].type),g.changeSource(h[0]);b.isMobileDevice()&&g.mediaElement[0].load(),a(function(){g.autoPlay&&!b.isMobileDevice()&&g.play()}),""==c&&g.onVideoError()},g.mediaElement=e.find(f.vgType),g.sources=d.vgSrc,g.addListeners(),g.onVideoReady(),d.$watch("vgSrc",d.onChangeSource),d.$watch(function(){return g.sources},d.onChangeSource),d.$watch(function(){return g.playsInline},function(a,b){a?g.mediaElement.attr("webkit-playsinline",""):g.mediaElement.removeAttr("webkit-playsinline")}),g.isConfig&&d.$watch(function(){return g.config},function(){g.config&&(d.vgSrc=g.config.sources)})}}}]),angular.module("com.2fdevs.videogular").directive("vgNativeControls",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setControls=function(a){a?d.mediaElement.attr("controls",a):d.mediaElement.removeAttr("controls")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setControls(d.config.controls)}):a.$watch(c.vgNativeControls,function(b,c){e&&b==c||!b?a.setControls():(e=b,a.setControls(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgPreload",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setPreload=function(a){a?d.mediaElement.attr("preload",a):d.mediaElement.removeAttr("preload")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setPreload(d.config.preload)}):a.$watch(c.vgPreload,function(b,c){e&&b==c||!b?a.setPreload():(e=b,a.setPreload(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgTracks",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e,f,g,h=!1;a.onLoadMetaData=function(){h=!0,a.updateTracks()},a.updateTracks=function(){var b=d.mediaElement.children();for(f=0,g=b.length;g>f;f++)b[f].remove&&b[f].remove();if(e)for(f=0,g=e.length;g>f;f++){var c=document.createElement("track");for(var h in e[f])c[h]=e[f][h];c.addEventListener("load",a.onLoadTrack.bind(a,c)),d.mediaElement[0].appendChild(c)}},a.onLoadTrack=function(b){b["default"]?b.mode="showing":b.mode="hidden";for(var c=0,e=d.mediaElement[0].textTracks.length;e>c;c++)b.label==d.mediaElement[0].textTracks[c].label&&(b["default"]?d.mediaElement[0].textTracks[c].mode="showing":d.mediaElement[0].textTracks[c].mode="disabled");b.removeEventListener("load",a.onLoadTrack.bind(a,b))},a.setTracks=function(b){e=b,d.tracks=b,h?a.updateTracks():d.mediaElement[0].addEventListener("loadedmetadata",a.onLoadMetaData.bind(a),!1)},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setTracks(d.config.tracks)}):a.$watch(c.vgTracks,function(b,c){e&&b==c||a.setTracks(b)},!0)}}}}]),angular.module("com.2fdevs.videogular").directive("videogular",[function(){return{restrict:"EA",scope:{vgTheme:"=?",vgAutoPlay:"=?",vgPlaysInline:"=?",vgNativeFullscreen:"=?",vgClearMediaOnNavigate:"=?",vgCuePoints:"=?",vgConfig:"@",vgCanPlay:"&",vgComplete:"&",vgUpdateVolume:"&",vgUpdatePlayback:"&",vgUpdateTime:"&",vgUpdateState:"&",vgPlayerReady:"&",vgChangeSource:"&",vgSeeking:"&",vgSeeked:"&",vgError:"&"},controller:"vgController",controllerAs:"API",link:{pre:function(a,b,c,d){d.videogularElement=angular.element(b)}}}}]),angular.module("com.2fdevs.videogular").service("vgConfigLoader",["$http","$q","$sce",function(a,b,c){this.loadConfig=function(d){var e=b.defer();return a({method:"GET",url:d}).then(function(a){for(var b=a.data,d=0,f=b.sources.length;f>d;d++)b.sources[d].src=c.trustAsResourceUrl(b.sources[d].src);e.resolve(b)},function(){e.reject()}),e.promise}}]),angular.module("com.2fdevs.videogular").service("vgFullscreen",["VG_UTILS",function(a){function b(){var a=!1;return a=c?null!=document[d.element]||c.webkitDisplayingFullscreen:null!=document[d.element]}var c,d=null,e={w3:{enabled:"fullscreenEnabled",element:"fullscreenElement",request:"requestFullscreen",exit:"exitFullscreen",onchange:"fullscreenchange",onerror:"fullscreenerror"},newWebkit:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitRequestFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},oldWebkit:{enabled:"webkitIsFullScreen",element:"webkitCurrentFullScreenElement",request:"webkitRequestFullScreen",exit:"webkitCancelFullScreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},moz:{enabled:"mozFullScreen",element:"mozFullScreenElement",request:"mozRequestFullScreen",exit:"mozCancelFullScreen",onchange:"mozfullscreenchange",onerror:"mozfullscreenerror"},ios:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitEnterFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},ms:{enabled:"msFullscreenEnabled",element:"msFullscreenElement",request:"msRequestFullscreen",exit:"msExitFullscreen",onchange:"MSFullscreenChange",onerror:"MSFullscreenError"}};for(var f in e)if(e[f].enabled in document){d=e[f];break}a.isiOSDevice()&&(d=e.ios),this.isAvailable=null!=d,d&&(this.onchange=d.onchange,this.onerror=d.onerror,this.isFullScreen=b,this.exit=function(){document[d.exit]()},this.request=function(a){c=a,c[d.request]()})}]),angular.module("com.2fdevs.videogular").service("VG_UTILS",["$window",function(a){this.fixEventOffset=function(a){var b=navigator.userAgent.match(/Firefox\/(\d+)/i);if(b&&Number.parseInt(b.pop())<39){var c=a.currentTarget.currentStyle||window.getComputedStyle(a.target,null),d=parseInt(c.borderLeftWidth,10),e=parseInt(c.borderTopWidth,10),f=a.currentTarget.getBoundingClientRect(),g=a.clientX-d-f.left,h=a.clientY-e-f.top;a.offsetX=g,a.offsetY=h}return a},this.getZIndex=function(){for(var a,b=1,c=document.getElementsByTagName("*"),d=0,e=c.length;e>d;d++)a=parseInt(window.getComputedStyle(c[d])["z-index"]),a>b&&(b=a+1);return b},this.isMobileDevice=function(){return"undefined"!=typeof window.orientation||-1!==navigator.userAgent.indexOf("IEMobile")},this.isiOSDevice=function(){return navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/iPad/i)},this.supportsLocalStorage=function(){var b="videogular-test-key",c=a.sessionStorage;try{return c.setItem(b,"1"),c.removeItem(b),"localStorage"in a&&null!==a.localStorage}catch(d){return!1}}}]); \ No newline at end of file
+"use strict";angular.module("com.2fdevs.videogular",["ngSanitize"]).run(["$templateCache",function(a){a.put("vg-templates/vg-media-video","<video></video>"),a.put("vg-templates/vg-media-audio","<audio></audio>"),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e})}]),angular.module("com.2fdevs.videogular").constant("VG_STATES",{PLAY:"play",PAUSE:"pause",STOP:"stop"}).constant("VG_VOLUME_KEY","videogularVolume"),angular.module("com.2fdevs.videogular").controller("vgController",["$scope","$window","vgConfigLoader","vgFullscreen","VG_UTILS","VG_STATES","VG_VOLUME_KEY",function(a,b,c,d,e,f,g){var h=null,i=!1,j=!1,k=!1,l=!1;this.videogularElement=null,this.clearMedia=function(){this.mediaElement[0].src="",this.mediaElement[0].removeEventListener("canplay",this.onCanPlay.bind(this),!1),this.mediaElement[0].removeEventListener("loadedmetadata",this.onLoadMetaData.bind(this),!1),this.mediaElement[0].removeEventListener("waiting",this.onStartBuffering.bind(this),!1),this.mediaElement[0].removeEventListener("ended",this.onComplete.bind(this),!1),this.mediaElement[0].removeEventListener("playing",this.onStartPlaying.bind(this),!1),this.mediaElement[0].removeEventListener("play",this.onPlay.bind(this),!1),this.mediaElement[0].removeEventListener("pause",this.onPause.bind(this),!1),this.mediaElement[0].removeEventListener("volumechange",this.onVolumeChange.bind(this),!1),this.mediaElement[0].removeEventListener("playbackchange",this.onPlaybackChange.bind(this),!1),this.mediaElement[0].removeEventListener("timeupdate",this.onUpdateTime.bind(this),!1),this.mediaElement[0].removeEventListener("progress",this.onProgress.bind(this),!1),this.mediaElement[0].removeEventListener("seeking",this.onSeeking.bind(this),!1),this.mediaElement[0].removeEventListener("seeked",this.onSeeked.bind(this),!1),this.mediaElement[0].removeEventListener("error",this.onVideoError.bind(this),!1)},this.onRouteChange=function(){(void 0===this.clearMediaOnNavigate||this.clearMediaOnNavigate===!0)&&this.clearMedia()},this.onCanPlay=function(b){this.isBuffering=!1,a.$parent.$digest(a.vgCanPlay({$event:b})),!k&&(this.startTime>0||0===this.startTime)&&(this.seekTime(this.startTime),k=!0)},this.onVideoReady=function(){this.isReady=!0,this.autoPlay=a.vgAutoPlay,this.playsInline=a.vgPlaysInline,this.nativeFullscreen=a.vgNativeFullscreen||!0,this.cuePoints=a.vgCuePoints,this.startTime=a.vgStartTime,this.virtualClipDuration=a.vgVirtualClipDuration,this.clearMediaOnNavigate=a.vgClearMediaOnNavigate||!0,this.currentState=f.STOP,j=!0,l=this.startTime>=0&&this.virtualClipDuration>0,e.supportsLocalStorage()&&this.setVolume(parseFloat(b.localStorage.getItem(g)||"1")),a.vgConfig?c.loadConfig(a.vgConfig).then(this.onLoadConfig.bind(this)):a.vgPlayerReady({$API:this})},this.onLoadConfig=function(b){this.config=b,a.vgTheme=this.config.theme,a.vgAutoPlay=this.config.autoPlay,a.vgPlaysInline=this.config.playsInline,a.vgNativeFullscreen=this.config.nativeFullscreen,a.vgCuePoints=this.config.cuePoints,a.vgClearMediaOnNavigate=this.config.clearMediaOnNavigate,a.vgStartTime=this.config.startTime,a.vgVirtualClipDuration=this.config.virtualClipDuration,l=a.vgStartTime>=0&&a.vgVirtualClipDuration>0,a.vgPlayerReady({$API:this})},this.onLoadMetaData=function(a){this.isBuffering=!1,this.onUpdateTime(a)},this.onProgress=function(b){this.updateBuffer(b),a.$parent.$digest()},this.updateBuffer=function(a){a.target.buffered.length&&(this.buffered=a.target.buffered,this.bufferEnd=1e3*a.target.buffered.end(a.target.buffered.length-1),this.bufferEnd>this.totalTime&&(this.bufferEnd=this.totalTime))},this.onUpdateTime=function(b){var c=1e3*b.target.currentTime;this.updateBuffer(b),b.target.duration!=1/0&&null!=b.target.duration&&void 0!=b.target.duration&&1.7976931348623157e308!=b.target.duration?(l?k&&(b.target.currentTime<this.startTime||b.target.currentTime-this.startTime>this.virtualClipDuration)?this.onComplete():(this.currentTime=Math.max(0,c-1e3*this.startTime),this.totalTime=1e3*this.virtualClipDuration,this.timeLeft=1e3*this.virtualClipDuration-this.currentTime):(this.currentTime=c,this.totalTime=1e3*b.target.duration,this.timeLeft=1e3*(b.target.duration-b.target.currentTime)),this.isLive=!1):(this.currentTime=c,this.isLive=!0);var d=l?this.currentTime/1e3:b.target.currentTime,e=l?this.totalTime/1e3:b.target.duration;this.cuePoints&&this.checkCuePoints(d),a.vgUpdateTime({$currentTime:d,$duration:e}),"$apply"!=a.$$phase&&"$digest"!=a.$$phase&&a.$parent.$digest()},this.checkCuePoints=function(a){for(var b in this.cuePoints)for(var c=0,d=this.cuePoints[b].length;d>c;c++){var e=this.cuePoints[b][c],f=parseInt(a,10),g=parseInt(e.timeLapse.start,10);e.timeLapse.end||(e.timeLapse.end=e.timeLapse.start+1),a<e.timeLapse.end&&(e.$$isCompleted=!1),e.$$isDirty||f!==g||"function"!=typeof e.onEnter||(e.onEnter(a,e.timeLapse,e.params),e.$$isDirty=!0),a>e.timeLapse.start?(a<e.timeLapse.end&&(e.onUpdate&&e.onUpdate(a,e.timeLapse,e.params),e.$$isDirty||"function"!=typeof e.onEnter||e.onEnter(a,e.timeLapse,e.params)),a>=e.timeLapse.end&&e.onComplete&&!e.$$isCompleted&&(e.$$isCompleted=!0,e.onComplete(a,e.timeLapse,e.params)),e.$$isDirty=!0):(e.onLeave&&e.$$isDirty&&e.onLeave(a,e.timeLapse,e.params),e.$$isDirty=!1)}},this.onPlay=function(){this.setState(f.PLAY),a.$parent.$digest()},this.onPause=function(){var b=l?this.currentTime:this.mediaElement[0].currentTime;0==b?this.setState(f.STOP):this.setState(f.PAUSE),a.$parent.$digest()},this.onVolumeChange=function(){this.volume=this.mediaElement[0].volume,a.$parent.$digest()},this.onPlaybackChange=function(){this.playback=this.mediaElement[0].playbackRate,a.$parent.$digest()},this.onSeeking=function(b){a.vgSeeking({$currentTime:b.target.currentTime,$duration:b.target.duration})},this.onSeeked=function(b){a.vgSeeked({$currentTime:b.target.currentTime,$duration:b.target.duration})},this.seekTime=function(a,b){var c;if(b)l?(a=Math.max(0,Math.min(a,100)),c=a*this.virtualClipDuration/100,this.mediaElement[0].currentTime=this.startTime+c):(c=a*this.mediaElement[0].duration/100,this.mediaElement[0].currentTime=c);else if(l){var d=a/this.mediaElement[0].duration;c=k?this.virtualClipDuration*d:0,this.mediaElement[0].currentTime=k?this.startTime+c:this.startTime}else c=a,this.mediaElement[0].currentTime=c;this.currentTime=1e3*c},this.playPause=function(){this.mediaElement[0].paused?this.play():this.pause()},this.setState=function(b){return b&&b!=this.currentState&&(a.vgUpdateState({$state:b}),this.currentState=b),this.currentState},this.play=function(){this.mediaElement[0].play(),this.setState(f.PLAY)},this.pause=function(){this.mediaElement[0].pause(),this.setState(f.PAUSE)},this.stop=function(){try{this.mediaElement[0].pause();var a=l?this.startTime:0;this.mediaElement[0].currentTime=a,this.currentTime=a,this.buffered=[],this.bufferEnd=0,this.setState(f.STOP)}catch(b){return b}},this.toggleFullScreen=function(){d.isAvailable&&this.nativeFullscreen?this.isFullScreen?e.isMobileDevice()||d.exit():e.isMobileDevice()?e.isiOSDevice()?j?this.enterElementInFullScreen(this.mediaElement[0]):(i=!0,this.play()):this.enterElementInFullScreen(this.mediaElement[0]):this.enterElementInFullScreen(this.videogularElement[0]):(this.isFullScreen?(this.videogularElement.removeClass("fullscreen"),this.videogularElement.css("z-index","auto")):(this.videogularElement.addClass("fullscreen"),this.videogularElement.css("z-index",e.getZIndex())),this.isFullScreen=!this.isFullScreen)},this.enterElementInFullScreen=function(a){d.request(a)},this.changeSource=function(b){a.vgChangeSource({$source:b})},this.setVolume=function(c){c=Math.max(Math.min(c,1),0),a.vgUpdateVolume({$volume:c}),this.mediaElement[0].volume=c,this.volume=c,e.supportsLocalStorage()&&b.localStorage.setItem(g,c.toString())},this.setPlayback=function(b){a.vgUpdatePlayback({$playBack:b}),this.mediaElement[0].playbackRate=b,this.playback=b},this.updateTheme=function(a){var b,c,d=document.getElementsByTagName("link");if(h)for(b=0,c=d.length;c>b;b++)if(d[b].outerHTML.indexOf(h)>=0){d[b].parentNode.removeChild(d[b]);break}if(a){var e=angular.element(document).find("head"),f=!1;for(b=0,c=d.length;c>b&&!(f=d[b].outerHTML.indexOf(a)>=0);b++);f||e.append("<link rel='stylesheet' href='"+a+"'>"),h=a}},this.onStartBuffering=function(b){this.isBuffering=!0,a.$parent.$digest()},this.onStartPlaying=function(b){this.isBuffering=!1,a.$parent.$digest()},this.onComplete=function(b){a.vgComplete(),this.setState(f.STOP),this.isCompleted=!0,l&&this.stop(),a.$parent.$digest()},this.onVideoError=function(b){a.vgError({$event:b})},this.addListeners=function(){this.mediaElement[0].addEventListener("canplay",this.onCanPlay.bind(this),!1),this.mediaElement[0].addEventListener("loadedmetadata",this.onLoadMetaData.bind(this),!1),this.mediaElement[0].addEventListener("waiting",this.onStartBuffering.bind(this),!1),this.mediaElement[0].addEventListener("ended",this.onComplete.bind(this),!1),this.mediaElement[0].addEventListener("playing",this.onStartPlaying.bind(this),!1),this.mediaElement[0].addEventListener("play",this.onPlay.bind(this),!1),this.mediaElement[0].addEventListener("pause",this.onPause.bind(this),!1),this.mediaElement[0].addEventListener("volumechange",this.onVolumeChange.bind(this),!1),this.mediaElement[0].addEventListener("playbackchange",this.onPlaybackChange.bind(this),!1),this.mediaElement[0].addEventListener("timeupdate",this.onUpdateTime.bind(this),!1),this.mediaElement[0].addEventListener("progress",this.onProgress.bind(this),!1),this.mediaElement[0].addEventListener("seeking",this.onSeeking.bind(this),!1),this.mediaElement[0].addEventListener("seeked",this.onSeeked.bind(this),!1),this.mediaElement[0].addEventListener("error",this.onVideoError.bind(this),!1)},this.init=function(){this.isReady=!1,this.isCompleted=!1,this.buffered=[],this.bufferEnd=0,this.currentTime=0,this.totalTime=0,this.timeLeft=0,this.isLive=!1,this.isFullScreen=!1,this.playback=1,this.isConfig=void 0!=a.vgConfig,this.mediaElement=[{play:function(){},pause:function(){},stop:function(){},addEventListener:function(){},removeEventListener:function(){}}],d.isAvailable&&(this.isFullScreen=d.isFullScreen()),this.updateTheme(a.vgTheme),this.addBindings(),d.isAvailable&&document.addEventListener(d.onchange,this.onFullScreenChange.bind(this))},this.onUpdateTheme=function(a){this.updateTheme(a)},this.onUpdateAutoPlay=function(a){a&&!this.autoPlay&&(this.autoPlay=a,this.play(this))},this.onUpdateStartTime=function(a){if(a&&a!=this.startTime){this.mediaElement[0].currentTime=a,this.startTime=a,l=this.startTime>=0&&this.virtualClipDuration>0;var b={target:this.mediaElement[0]};this.onUpdateTime(b,!0)}},this.onUpdateVirtualClipDuration=function(a){if(a&&a!=this.virtualClipDuration){this.virtualClipDuration=a,l=this.startTime>=0&&this.virtualClipDuration>0;var b={target:this.mediaElement[0]};this.onUpdateTime(b,!0)}},this.onUpdatePlaysInline=function(a){this.playsInline=a},this.onUpdateNativeFullscreen=function(a){void 0==a&&(a=!0),this.nativeFullscreen=a},this.onUpdateCuePoints=function(a){this.cuePoints=a,this.checkCuePoints(this.currentTime)},this.onUpdateClearMediaOnNavigate=function(a){this.clearMediaOnNavigate=a},this.addBindings=function(){a.$watch("vgTheme",this.onUpdateTheme.bind(this)),a.$watch("vgAutoPlay",this.onUpdateAutoPlay.bind(this)),a.$watch("vgStartTime",this.onUpdateStartTime.bind(this)),a.$watch("vgVirtualClipDuration",this.onUpdateVirtualClipDuration.bind(this)),a.$watch("vgPlaysInline",this.onUpdatePlaysInline.bind(this)),a.$watch("vgNativeFullscreen",this.onUpdateNativeFullscreen.bind(this)),a.$watch("vgCuePoints",this.onUpdateCuePoints.bind(this)),a.$watch("vgClearMediaOnNavigate",this.onUpdateClearMediaOnNavigate.bind(this))},this.onFullScreenChange=function(b){this.isFullScreen=d.isFullScreen(),a.$parent.$digest()},a.$on("$destroy",this.clearMedia.bind(this)),a.$on("$routeChangeStart",this.onRouteChange.bind(this)),this.init()}]),angular.module("com.2fdevs.videogular").directive("vgCrossorigin",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setCrossorigin=function(a){a?d.mediaElement.attr("crossorigin",a):d.mediaElement.removeAttr("crossorigin")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setCrossorigin(d.config.crossorigin)}):a.$watch(c.vgCrossorigin,function(b,c){e&&b==c||!b?a.setCrossorigin():(e=b,a.setCrossorigin(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgLoop",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setLoop=function(a){a?d.mediaElement.attr("loop",a):d.mediaElement.removeAttr("loop")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setLoop(d.config.loop)}):a.$watch(c.vgLoop,function(b,c){e&&b==c||!b?a.setLoop():(e=b,a.setLoop(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgMedia",["$timeout","VG_UTILS","VG_STATES",function(a,b,c){return{restrict:"E",require:"^videogular",templateUrl:function(a,b){var c=b.vgType||"video";return b.vgTemplate||"vg-templates/vg-media-"+c},scope:{vgSrc:"=?",vgType:"=?"},link:function(d,e,f,g){var h;f.vgType&&"video"!==f.vgType?f.vgType="audio":f.vgType="video",d.onChangeSource=function(a,b){h&&a==b||!a||(h=a,g.currentState!==c.PLAY&&(g.currentState=c.STOP),g.sources=h,d.changeSource())},d.changeSource=function(){if(angular.isArray(h)){var c="";if(g.mediaElement[0].canPlayType){for(var d=0,e=h.length;e>d;d++)if(c=g.mediaElement[0].canPlayType(h[d].type),"maybe"==c||"probably"==c){g.mediaElement.attr("src",h[d].src),g.mediaElement.attr("type",h[d].type),g.changeSource(h[d]);break}}else g.mediaElement.attr("src",h[0].src),g.mediaElement.attr("type",h[0].type),g.changeSource(h[0])}else g.mediaElement.attr("src",h),g.changeSource(h);b.isMobileDevice()&&g.mediaElement[0].load(),a(function(){!g.autoPlay||!b.isCordova()&&b.isMobileDevice()||g.play()}),""==c&&g.onVideoError()},g.mediaElement=e.find(f.vgType),g.sources=d.vgSrc,g.addListeners(),g.onVideoReady(),d.$watch("vgSrc",d.onChangeSource),d.$watch(function(){return g.sources},d.onChangeSource),d.$watch(function(){return g.playsInline},function(a,b){a?g.mediaElement.attr("webkit-playsinline",""):g.mediaElement.removeAttr("webkit-playsinline")}),g.isConfig&&d.$watch(function(){return g.config},function(){g.config&&(d.vgSrc=g.config.sources)})}}}]),angular.module("com.2fdevs.videogular").directive("vgNativeControls",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setControls=function(a){a?d.mediaElement.attr("controls",a):d.mediaElement.removeAttr("controls")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setControls(d.config.controls)}):a.$watch(c.vgNativeControls,function(b,c){e&&b==c||!b?a.setControls():(e=b,a.setControls(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgPreload",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e;a.setPreload=function(a){a?d.mediaElement.attr("preload",a):d.mediaElement.removeAttr("preload")},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setPreload(d.config.preload)}):a.$watch(c.vgPreload,function(b,c){e&&b==c||!b?a.setPreload():(e=b,a.setPreload(e))})}}}}]),angular.module("com.2fdevs.videogular").directive("vgTracks",[function(){return{restrict:"A",require:"^videogular",link:{pre:function(a,b,c,d){var e,f,g,h=!1;a.onLoadMetaData=function(){h=!0,a.updateTracks()},a.updateTracks=function(){var b=d.mediaElement.children();for(f=0,g=b.length;g>f;f++)b[f].remove&&b[f].remove();if(e)for(f=0,g=e.length;g>f;f++){var c=document.createElement("track");for(var h in e[f])c[h]=e[f][h];c.addEventListener("load",a.onLoadTrack.bind(a,c)),d.mediaElement[0].appendChild(c)}},a.onLoadTrack=function(b){b["default"]?b.mode="showing":b.mode="hidden";for(var c=0,e=d.mediaElement[0].textTracks.length;e>c;c++)b.label==d.mediaElement[0].textTracks[c].label&&(b["default"]?d.mediaElement[0].textTracks[c].mode="showing":d.mediaElement[0].textTracks[c].mode="disabled");b.removeEventListener("load",a.onLoadTrack.bind(a,b))},a.setTracks=function(b){e=b,d.tracks=b,h?a.updateTracks():d.mediaElement[0].addEventListener("loadedmetadata",a.onLoadMetaData.bind(a),!1)},d.isConfig?a.$watch(function(){return d.config},function(){d.config&&a.setTracks(d.config.tracks)}):a.$watch(c.vgTracks,function(b,c){e&&b==c||a.setTracks(b)},!0)}}}}]),angular.module("com.2fdevs.videogular").directive("videogular",[function(){return{restrict:"EA",scope:{vgTheme:"=?",vgAutoPlay:"=?",vgStartTime:"=?",vgVirtualClipDuration:"=?",vgPlaysInline:"=?",vgNativeFullscreen:"=?",vgClearMediaOnNavigate:"=?",vgCuePoints:"=?",vgConfig:"@",vgCanPlay:"&",vgComplete:"&",vgUpdateVolume:"&",vgUpdatePlayback:"&",vgUpdateTime:"&",vgUpdateState:"&",vgPlayerReady:"&",vgChangeSource:"&",vgSeeking:"&",vgSeeked:"&",vgError:"&"},controller:"vgController",controllerAs:"API",link:{pre:function(a,b,c,d){d.videogularElement=angular.element(b)}}}}]),angular.module("com.2fdevs.videogular").service("vgConfigLoader",["$http","$q","$sce",function(a,b,c){this.loadConfig=function(d){var e=b.defer();return a({method:"GET",url:d}).then(function(a){for(var b=a.data,d=0,f=b.sources.length;f>d;d++)b.sources[d].src=c.trustAsResourceUrl(b.sources[d].src);e.resolve(b)},function(){e.reject()}),e.promise}}]),angular.module("com.2fdevs.videogular").service("vgFullscreen",["VG_UTILS",function(a){function b(){var a=!1;return a=c?null!=document[d.element]||c.webkitDisplayingFullscreen:null!=document[d.element]}var c,d=null,e={w3:{enabled:"fullscreenEnabled",element:"fullscreenElement",request:"requestFullscreen",exit:"exitFullscreen",onchange:"fullscreenchange",onerror:"fullscreenerror"},newWebkit:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitRequestFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},oldWebkit:{enabled:"webkitIsFullScreen",element:"webkitCurrentFullScreenElement",request:"webkitRequestFullScreen",exit:"webkitCancelFullScreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},moz:{enabled:"mozFullScreen",element:"mozFullScreenElement",request:"mozRequestFullScreen",exit:"mozCancelFullScreen",onchange:"mozfullscreenchange",onerror:"mozfullscreenerror"},ios:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitEnterFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},ms:{enabled:"msFullscreenEnabled",element:"msFullscreenElement",request:"msRequestFullscreen",exit:"msExitFullscreen",onchange:"MSFullscreenChange",onerror:"MSFullscreenError"}};for(var f in e)if(e[f].enabled in document){d=e[f];break}a.isiOSDevice()&&(d=e.ios),this.isAvailable=null!=d,d&&(this.onchange=d.onchange,this.onerror=d.onerror,this.isFullScreen=b,this.exit=function(){document[d.exit]()},this.request=function(a){c=a,c[d.request]()})}]),angular.module("com.2fdevs.videogular").service("VG_UTILS",["$window",function(a){this.fixEventOffset=function(a){var b=navigator.userAgent.match(/Firefox\/(\d+)/i);if(b&&Number.parseInt(b.pop())<39){var c=a.currentTarget.currentStyle||window.getComputedStyle(a.target,null),d=parseInt(c.borderLeftWidth,10),e=parseInt(c.borderTopWidth,10),f=a.currentTarget.getBoundingClientRect(),g=a.clientX-d-f.left,h=a.clientY-e-f.top;a.offsetX=g,a.offsetY=h}return a},this.getZIndex=function(){for(var a,b=1,c=document.getElementsByTagName("*"),d=0,e=c.length;e>d;d++)a=parseInt(window.getComputedStyle(c[d])["z-index"]),a>b&&(b=a+1);return b},this.isMobileDevice=function(){return"undefined"!=typeof window.orientation||-1!==navigator.userAgent.indexOf("IEMobile")},this.isiOSDevice=function(){return navigator.userAgent.match(/ip(hone|ad|od)/i)&&!navigator.userAgent.match(/(iemobile)[\/\s]?([\w\.]*)/i)},this.isCordova=function(){return-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://")},this.supportsLocalStorage=function(){var b="videogular-test-key";try{var c=a.sessionStorage;return c.setItem(b,"1"),c.removeItem(b),"localStorage"in a&&null!==a.localStorage}catch(d){return!1}}}]); \ No newline at end of file