/* media media is a wrapper around the swfobject script It includes our default colors, and logic to embed the correct skin file, use the correct streaming server, and other vars. It should simplify embedding videos on other pages. */ function media(conf) { var w=257; var h=193; // colors var backcolor = '003366'; var frontcolor = 'AABBCC'; var lightcolor = 'FECC66'; var screencolor = '333333'; var autostart = '&autostart=false'; var controlbar = '&controlbar=over'; var usefullscreen = true; var posterframe = ''; var skin = '&skin=/js/jwplayer/snel-small.swf'; var streamingServer = '&streamer=rtmp://seed.law.upenn.edu/public/_definst_'; var type = ''; // By default, stream media, but allow for HTTP connections (streaming=false) if ( conf.streaming != undefined ) { if ( !conf.streaming ) { streamingServer = ''; } else { streamingServer = '&streamer=' + conf.streaming; } } if (conf.type == "audio") { h=23; controlbar = ''; skin = '&skin=/js/jwplayer/snel-small-no-fullscreen.swf'; //streamingServer=''; type = '&type=sound'; usefullscreen = false; } if (conf.type == "filmstrip") { //streamingServer=''; } if ( conf.type == "rtmp" || conf.type == "live" ) { streamingServer = '&streamer=rtmp://seed1.law.upenn.edu/live/_definst_'; type = '&type=rtmp'; } if ( conf.autostart != undefined ) autostart = '&autostart=true'; if ( conf.image != undefined ) posterframe = '&image=' + conf.image; // JW Player determines the media type for tracks in playlists of any sort if ( conf.playlist.match(/.xml/) ) type = ''; var so = new SWFObject('/js/jwplayer/player.swf',conf.ID,w,h,'9'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('usefullscreen',usefullscreen); so.addVariable('repeat','list'); so.addParam('flashvars','&file='+conf.playlist+autostart+posterframe+controlbar+'&displaytitle=true&playlist=none' + skin + type + '&repeat=list&stretching=exactfit&backcolor=' + backcolor + '&frontcolor=' + frontcolor + '&lightcolor=' + lightcolor + '&screencolor=' + screencolor + streamingServer); return so; } /* play play provides access to the JW Player's play function. Specify the player ID to play from the first clip, or specify the player ID and a clip number to play a specific clip. */ function play(mp,clip) { if ( clip == undefined ) clip = 0; if ( document.getElementById(mp) ) { var player = document.getElementById(mp); player.sendEvent('ITEM',clip); } else { alert("The media player, [" + mp + "], has not yet loaded."); } } /* playerReady playerReady is called by JW Player when the player has fully loaded. We add a listener to the player to call nowPlaying when a new playing item is selected. */ function playerReady(obj) { document.getElementById(obj.id).addControllerListener('ITEM', 'nowPlaying'); } /* nowPlaying nowPlaying is called when a new item is played in JW Player. If the playlist contains multiple items: - Create a caption item, if none exists - Insert current clip title into the caption */ function nowPlaying(obj) { // Update caption element if the playlist contains more than 1 item if ( document.getElementById(obj.id).getPlaylist().length > 1 ) { // If there is no existing caption element for this player, create a caption element if ( !document.getElementById(obj.id+'_caption') ) { var newNode = document.createElement("div"); newNode.id = obj.id + "_caption"; newNode.className = "caption"; document.getElementById(obj.id).parentNode.parentNode.insertBefore(newNode, document.getElementById(obj.id).parentNode.nextSibling); } var caption = document.getElementById(obj.id+'_caption'); caption.innerHTML = 'Now Playing: ' + document.getElementById(obj.id).getPlaylist()[obj.index].title; } }