Created
December 3, 2014 20:58
-
-
Save steadystatic/82b11548494965779347 to your computer and use it in GitHub Desktop.
bower-video-angular flash fallback fix attempt
This file contains hidden or 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
| diff --git flash.js flash.js | |
| index ce8d6e9..f363b1f 100644 | |
| --- flash.js | |
| +++ flash.js | |
| @@ -1,8 +1,8 @@ | |
| "use strict"; | |
| angular.module("info.vietnamcode.nampnq.videogular.plugins.flash", []) | |
| .directive( | |
| - "vgFlashPlayer", ["VG_EVENTS", "VG_STATES", "$rootScope", "$window", '$timeout', | |
| - function(VG_EVENTS, VG_STATES, $rootScope, $window, $timeout) { | |
| + "vgFlashPlayer", ["VG_STATES", "$rootScope", "$window", '$timeout', | |
| + function(VG_STATES, $rootScope, $window, $timeout) { | |
| return { | |
| restrict: "E", | |
| require: "^videogular", | |
| @@ -28,15 +28,15 @@ angular.module("info.vietnamcode.nampnq.videogular.plugins.flash", []) | |
| console.log(arguments); | |
| if (eventName == "waiting") { | |
| videogularElementScope.onStartBuffering({ | |
| - target: API.videoElement[0] | |
| + target: API.videogularElement[0].firstChild | |
| }) | |
| } else if (eventName == "ended") { | |
| videogularElementScope.onComplete({ | |
| - target: API.videoElement[0] | |
| + target: API.videogularElement[0].firstChild | |
| }); | |
| } else if (eventName == "playing") { | |
| videogularElementScope.onStartPlaying({ | |
| - target: API.videoElement[0] | |
| + target: API.videogularElement[0].firstChild | |
| }) | |
| } else if (eventName == "play") { | |
| videogularElementScope.updateSize(); | |
| @@ -63,56 +63,56 @@ angular.module("info.vietnamcode.nampnq.videogular.plugins.flash", []) | |
| } | |
| function setProperties() { | |
| - API.videoElement[0].vjs_setProperty("eventProxyFunction", "onSWFEvent"); | |
| - API.videoElement[0].vjs_setProperty("errorEventProxyFunction", "onSWFErrorEvent"); | |
| - API.videoElement[0].__defineGetter__("currentTime", function() { | |
| - return API.videoElement[0].vjs_getProperty("currentTime"); | |
| + API.flashVideoEle.vjs_setProperty("eventProxyFunction", "onSWFEvent"); | |
| + API.flashVideoEle.vjs_setProperty("errorEventProxyFunction", "onSWFErrorEvent"); | |
| + API.flashVideoEle.__defineGetter__("currentTime", function() { | |
| + return API.flashVideoEle.vjs_getProperty("currentTime"); | |
| }); | |
| - API.videoElement[0].__defineSetter__("currentTime", function(seconds) { | |
| - return API.videoElement[0].vjs_setProperty("currentTime", seconds); | |
| + API.flashVideoEle.__defineSetter__("currentTime", function(seconds) { | |
| + return API.flashVideoEle.vjs_setProperty("currentTime", seconds); | |
| }); | |
| - API.videoElement[0].__defineGetter__("duration", function() { | |
| - return API.videoElement[0].vjs_getProperty("duration"); | |
| + API.flashVideoEle.__defineGetter__("duration", function() { | |
| + return API.flashVideoEle.vjs_getProperty("duration"); | |
| }); | |
| - API.videoElement[0].__defineGetter__("paused", function() { | |
| - return API.videoElement[0].vjs_getProperty("paused"); | |
| + API.flashVideoEle.__defineGetter__("paused", function() { | |
| + return API.flashVideoEle.vjs_getProperty("paused"); | |
| }); | |
| - API.videoElement[0].__defineGetter__("videoWidth", function() { | |
| - return API.videoElement[0].vjs_getProperty("videoWidth"); | |
| + API.flashVideoEle.__defineGetter__("videoWidth", function() { | |
| + return API.flashVideoEle.vjs_getProperty("videoWidth"); | |
| }); | |
| - API.videoElement[0].__defineGetter__("videoHeight", function() { | |
| - return API.videoElement[0].vjs_getProperty("videoHeight"); | |
| + API.flashVideoEle.__defineGetter__("videoHeight", function() { | |
| + return API.flashVideoEle.vjs_getProperty("videoHeight"); | |
| }); | |
| - API.videoElement[0].__defineGetter__("volume", function() { | |
| - return API.videoElement[0].vjs_getProperty("volume"); | |
| + API.flashVideoEle.__defineGetter__("volume", function() { | |
| + return API.flashVideoEle.vjs_getProperty("volume"); | |
| }); | |
| - API.videoElement[0].__defineSetter__("volume", function(volume) { | |
| - return API.videoElement[0].vjs_setProperty("volume", volume); | |
| + API.flashVideoEle.__defineSetter__("volume", function(volume) { | |
| + return API.flashVideoEle.vjs_setProperty("volume", volume); | |
| }); | |
| - API.videoElement[0].play = function() { | |
| - API.videoElement[0].vjs_play(); | |
| + API.flashVideoEle.play = function() { | |
| + API.flashVideoEle.vjs_play(); | |
| } | |
| - API.videoElement[0].pause = function() { | |
| - API.videoElement[0].vjs_pause(); | |
| + API.flashVideoEle.pause = function() { | |
| + API.flashVideoEle.vjs_pause(); | |
| }; | |
| setInterval(function() { | |
| videogularElementScope.onUpdateTime({ | |
| - target: API.videoElement[0] | |
| + target: API.flashVideoEle | |
| }) | |
| }, 600); | |
| } | |
| function setSource(e) { | |
| - API.videoElement[0].vjs_src(result.url); | |
| + API.flashVideoEle.vjs_src(result.url); | |
| } | |
| function waitForSWF() { | |
| - API.videoElement = elem.find("#videoPlayer_" + scope.playerId); | |
| + API.flashVideoEle = $window.swfobject.getObjectById("videoPlayer_" + scope.playerId.toString()); | |
| console.log("Waiting for the SWF to be loaded..."); | |
| - if (API.videoElement[0].hasOwnProperty("vjs_setProperty")) { | |
| + if (API.flashVideoEle.hasOwnProperty("vjs_setProperty")) { | |
| setProperties(); | |
| setSource(); | |
| } else { | |
| @@ -141,17 +141,15 @@ angular.module("info.vietnamcode.nampnq.videogular.plugins.flash", []) | |
| id: "videoPlayer_" + scope.playerId, | |
| name: "videoPlayer_" + scope.playerId | |
| }; | |
| - $window.swfobject.createCSS("#videoPlayer_" + scope.playerId, "position: absolute;"); | |
| - $window.swfobject.embedSWF("video-js.swf", "videoPlayer_" + scope.playerId, "100%", "100%", "10.3", "", flashvars, params, attributes); | |
| - API.videoElement.remove(); | |
| + $window.swfobject.createCSS("#videoPlayer_" + scope.playerId, "position: static;"); | |
| + $window.swfobject.embedSWF("/js/lib/videogular/video-js.swf", "videoPlayer_" + scope.playerId, "300", "200", "10.3", "", flashvars, params, attributes); | |
| + API.videogularElement[0].firstChild.remove(); | |
| setTimeout(waitForSWF, 100); | |
| - | |
| - | |
| }; | |
| function getSource() { | |
| var i, n, src, type, media, mediaFiles = [], | |
| - htmlMediaElement = API.videoElement[0]; | |
| + htmlMediaElement = API.videogularElement[0].firstChild; | |
| for (i = 0; i < htmlMediaElement.childNodes.length; i++) { | |
| n = htmlMediaElement.childNodes[i]; | |
| if (n.nodeType == 1 && n.tagName.toLowerCase() == 'source') { |
Author
Author
API.flashVideoEle is just an arbitrary varialble on the same API object...I did it after my find/replace for the change with videoElement -> videogularElement borked some of that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I changed line 125 to /js/lib/videogular/video-js.swf was just for my Angular project...feel free to ignore that.