From: ScottDowne Date: Fri, 7 Jan 2011 20:16:26 +0000 (-0500) Subject: [#170] lower third plugin X-Git-Tag: v0.2~15^2~2^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=4a0a4373ca9f025a3131e57d44d45bf21eea6673;p=popcorn-js.git [#170] lower third plugin --- diff --git a/plugins/lowerThird/popcorn.lowerThird.html b/plugins/lowerThird/popcorn.lowerThird.html new file mode 100644 index 0000000..0543fd5 --- /dev/null +++ b/plugins/lowerThird/popcorn.lowerThird.html @@ -0,0 +1,56 @@ + + + + Popcorn Lower Third Plug-in Demo + + + + + + + +

Popcorn Lower Third Plug-in Demo

+

At 5 seconds info will appear in the lower third of the video and disappear at 15 seconds.

+

At 20 seconds info will appear in the lower third of the video and disappear at 45 seconds.

+
+ + +
+ + + diff --git a/plugins/lowerThird/popcorn.lowerThird.js b/plugins/lowerThird/popcorn.lowerThird.js new file mode 100644 index 0000000..7bcc6b4 --- /dev/null +++ b/plugins/lowerThird/popcorn.lowerThird.js @@ -0,0 +1,95 @@ +// PLUGIN: LowerThird + +(function (Popcorn) { + + /** + */ + + // just a little tool function + // calculates the top and left position of an element + var offset = function(elem) { + if(!elem) elem = this; + + var x = elem.offsetLeft; + var y = elem.offsetTop; + + while (elem = elem.offsetParent) { + x += elem.offsetLeft; + y += elem.offsetTop; + } + + return { left: x, top: y }; + } + + Popcorn.plugin( "lowerThird" , { + + manifest: { + about:{ + name: "Popcorn LowerThird Plugin", + version: "0.1", + author: "Scott Downe", + website: "http://scottdowne.wordpress.com/" + }, + options:{ + start : {elem:'input', type:'text', label:'In'}, + end : {elem:'input', type:'text', label:'Out'}, + target : 'LowerThird-container', + salutation : {elem:'input', type:'text', label:'Text'}, + name : {elem:'input', type:'text', label:'Text'}, + role : {elem:'input', type:'text', label:'Text'} + } + }, + + _setup: function( options ) { + + // Creates a div for all LowerThirds to use + if ( !this.container ) { + this.container = document.createElement('div'); + + this.container.style.position = "absolute"; + this.container.style.color = "white"; + this.container.style.textShadow = "black 2px 2px 6px"; + this.container.style.fontSize = "24px"; + this.container.style.fontWeight = "bold"; + this.container.style.paddingLeft = "40px"; + + // the video element must have height and width defined + this.container.style.width = this.video.offsetWidth + "px"; + this.container.style.left = offset( this.video ).left + "px"; + + this.video.parentNode.appendChild( this.container ); + } + + // if a target is specified, use that + if ( options.target && options.target !== 'LowerThird-container' ) { + options.container = document.getElementById( options.target ); + } else { // use shared default container + options.container = this.container; + } + + + + }, + /** + * @member lowerThird + * The start function will be executed when the currentTime + * of the video reaches the start time provided by the + * options variable + */ + start: function(event, options){ + options.container.innerHTML = ( options.salutation ? options.salutation + " " : "" ) + options.name + ( options.role ? "
" + options.role : "" ); + this.container.style.top = offset( this.video ).top + this.video.offsetHeight - ( 40 + this.container.offsetHeight ) + "px"; + }, + /** + * @member lowerThird + * The end function will be executed when the currentTime + * of the video reaches the end time provided by the + * options variable + */ + end: function(event, options){ + options.container.innerHTML = ""; + } + + } ); + +})( Popcorn );