From 0da3e149892f1fefe388f6d14f5b8b9399664d43 Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Tue, 29 Jun 2010 10:10:48 -0700 Subject: [PATCH] Image overlay support --- popcorn.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/popcorn.js b/popcorn.js index 03621ae..304cf00 100644 --- a/popcorn.js +++ b/popcorn.js @@ -47,6 +47,7 @@ if (commandObject.running && (commandObject.params["in"] > t || commandObject.params["out"] < t)) { commandObject.running = false; commandObject.onOut(); + commandObject.removeOverlay(); } } } @@ -60,6 +61,7 @@ if (!commandObject.running && commandObject.params["in"] < t && commandObject.params["out"] > t) { commandObject.running = true; commandObject.onIn(); + commandObject.displayOverlay(); } } } @@ -96,6 +98,8 @@ } }; + + //////////////////////////////////////////////////////////////////////////// // Command objects //////////////////////////////////////////////////////////////////////////// @@ -110,9 +114,13 @@ this.onIn = function() {}; this.onOut = function() {}; this.preload = function() {}; + this.displayOverlay = function() {}; + this.removeOverlay = function() {}; this.id = name + VideoCommand.count++; this.params["in"] = "0"; this.params["out"] = this.videoManager.videoElement.duration; + + // Adds all attributes from the xml tag into this.params for (var i = 0, pl = params.length; i < pl; i++) { for (var j = 0, nl = params[i].length; j < nl; j++) { var key = params[i].item(j).nodeName, @@ -133,6 +141,27 @@ } } } + + // Creates a div for all overlays to use + if (!VideoManager.overlayDiv) { + VideoManager.overlayDiv = document.createElement('div'); + VideoManager.overlayDiv.setAttribute('style', 'position:absolute;top:20px;left:20px'); + this.videoManager.videoElement.parentNode.appendChild(VideoManager.overlayDiv); + } + + // Checks for a url of an image to overlay onto the video + if (this.params.overlay) { + this.image = document.createElement('img'); + this.image.setAttribute('src', this.params.overlay); + this.image.setAttribute('style', 'display:none'); + VideoManager.overlayDiv.appendChild(this.image); + this.displayOverlay = function() { + this.image.setAttribute('style', 'display:inline'); + }; + this.removeOverlay = function() { + this.image.setAttribute('style', 'display:none'); + }; + } }; VideoCommand.count = 0; @@ -272,7 +301,7 @@ }; //////////////////////////////////////////////////////////////////////////// - // FlickrCommand Command + // Flickr Command //////////////////////////////////////////////////////////////////////////// var FlickrCommand = function(name, params, text, videoManager) { -- 2.43.0