summaryrefslogtreecommitdiff
path: root/www/lib/videogular-buffering/vg-buffering.js
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-11-01 06:33:26 -0500
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-11-01 06:33:26 -0500
commit2fe632d47c2c12aea423fdb837057d86d136e7c1 (patch)
tree5169c6a293e617a46cb4cd9d4ce872eea9c415a3 /www/lib/videogular-buffering/vg-buffering.js
parent5f452cb3add568b0b2dcc795e7885b6275f918e1 (diff)
inital commits - getting video branch to work #60 - implemented in quick scrub - works fine
Diffstat (limited to 'www/lib/videogular-buffering/vg-buffering.js')
-rw-r--r--www/lib/videogular-buffering/vg-buffering.js116
1 files changed, 116 insertions, 0 deletions
diff --git a/www/lib/videogular-buffering/vg-buffering.js b/www/lib/videogular-buffering/vg-buffering.js
new file mode 100644
index 00000000..fde9e839
--- /dev/null
+++ b/www/lib/videogular-buffering/vg-buffering.js
@@ -0,0 +1,116 @@
+/**
+ * @license videogular v1.3.2 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.
+ *
+ * <pre>
+ * <videogular vg-theme="config.theme.url" vg-autoplay="config.autoPlay">
+ * <vg-media vg-src="sources"></vg-media>
+ *
+ * <vg-buffering></vg-buffering>
+ * </videogular>
+ * </pre>
+ *
+ */
+"use strict";
+angular.module("com.2fdevs.videogular.plugins.buffering", [])
+ .run(
+ ["$templateCache", function ($templateCache) {
+ $templateCache.put("vg-templates/vg-buffering",
+ '<div class="bufferingContainer">\
+ <div ng-class="spinnerClass" class="loadingSpinner"></div>\
+ </div>');
+ }]
+)
+ .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);
+ }
+ }
+ );
+ }
+ }
+ }
+ ]);