From b28028ac4082842143b0f528d6bc539da6ccb419 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Thu, 21 Sep 2017 12:49:18 -0400 Subject: mega changes, including updates and X --- www/lib/videogular-buffering/vg-buffering.js | 116 +++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 www/lib/videogular-buffering/vg-buffering.js (limited to 'www/lib/videogular-buffering/vg-buffering.js') diff --git a/www/lib/videogular-buffering/vg-buffering.js b/www/lib/videogular-buffering/vg-buffering.js new file mode 100644 index 00000000..4691fce1 --- /dev/null +++ b/www/lib/videogular-buffering/vg-buffering.js @@ -0,0 +1,116 @@ +/** + * @license videogular v1.4.4 http://videogular.com + * Two Fucking Developers http://twofuckingdevelopers.com + * License: MIT + */ +/** + * @ngdoc directive + * @name com.2fdevs.videogular.plugins.buffering.directive:vgBuffering + * @restrict E + * @description + * Shows a spinner when Videogular is buffering or preparing the video player. + * + *
+ * 
+ *    
+ *
+ *    
+ * 
+ * 
+ * + */ +"use strict"; +angular.module("com.2fdevs.videogular.plugins.buffering", []) + .run( + ["$templateCache", function ($templateCache) { + $templateCache.put("vg-templates/vg-buffering", + '
\ +
\ +
'); + }] +) + .directive( + "vgBuffering", + ["VG_STATES", "VG_UTILS", function (VG_STATES, VG_UTILS) { + return { + restrict: "E", + require: "^videogular", + templateUrl: function (elem, attrs) { + return attrs.vgTemplate || 'vg-templates/vg-buffering'; + }, + link: function (scope, elem, attr, API) { + scope.showSpinner = function showSpinner() { + scope.spinnerClass = {stop: API.isBuffering}; + elem.css("display", "block"); + }; + + scope.hideSpinner = function hideSpinner() { + scope.spinnerClass = {stop: API.isBuffering}; + elem.css("display", "none"); + }; + + scope.setState = function setState(isBuffering) { + if (isBuffering) { + scope.showSpinner(); + } + else { + scope.hideSpinner(); + } + }; + + scope.onStateChange = function onStateChange(state) { + if (state == VG_STATES.STOP) { + scope.hideSpinner(); + } + }; + + scope.onPlayerReady = function onPlayerReady(isReady) { + if (isReady) { + scope.hideSpinner(); + } + }; + + scope.showSpinner(); + + // Workaround for issue #16: https://github.com/2fdevs/videogular/issues/16 + if (VG_UTILS.isMobileDevice()) { + scope.hideSpinner(); + } + else { + scope.$watch( + function () { + return API.isReady; + }, + function (newVal, oldVal) { + if (API.isReady == true || newVal != oldVal) { + scope.onPlayerReady(newVal); + } + } + ); + } + + scope.$watch( + function () { + return API.currentState; + }, + function (newVal, oldVal) { + if (newVal != oldVal) { + scope.onStateChange(newVal); + } + } + ); + + scope.$watch( + function () { + return API.isBuffering; + }, + function (newVal, oldVal) { + if (newVal != oldVal) { + scope.setState(newVal); + } + } + ); + } + } + } + ]); -- cgit v1.2.3