Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the ability to setVote from JavaScript

  • Loading branch information...
commit 9426e221dd9d9bb0146ecd431345fc98d06236fe 1 parent 7e25f08
Scott Alan Henry scottalan authored
2  com/tmtdigital/dash/display/voter/DashVoter.as
View
@@ -1 +1 @@
-/**
+/**
192 com/tmtdigital/dash/display/voter/Voter.as
View
@@ -1,191 +1 @@
-package com.tmtdigital.dash.display.voter
-{
- import com.tmtdigital.dash.display.Skinable;
- import com.tmtdigital.dash.events.DashEvent;
- import com.tmtdigital.dash.net.Service;
-
- // Import all dependencies
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
-
- // Declare our Voter class.
- public class Voter extends Skinable
- {
- // The Voter constructor.
- public function Voter( _skin:MovieClip, _userMode:Boolean = false )
- {
- userMode = _userMode;
- super( _skin );
- }
-
- // Sets the skin for our voter.
- public override function setSkin( _skin:MovieClip )
- {
- super.setSkin( _skin );
- nodeId = 0;
- tag = "vote";
- cache = false;
-
- if( skin ) {
- // Set the skin elements.
- votes = skin.votes;
- voter = skin.voter;
- selected = skin.selected;
-
- if( voter && voter.fill_mc ) {
- voter.fill_mc.width = 0;
- }
-
- if( selected && selected.fill_mc ) {
- selected.fill_mc.width = 0;
- }
-
- // Set the user mode.
- setUserMode();
- }
- }
-
- // Sets the user mode for this voter.
- private function setUserMode()
- {
- if( votes ) {
- votes.visible = userMode;
- }
-
- if( voter ) {
- voter.visible = userMode;
- }
-
- if( votes && userMode ) {
- // Iterate through all the hit regions.
- var i:int = votes.numChildren;
- while (i--)
- {
- // Get the vote at this location.
- var vote:* = votes.getChildAt(i);
-
- // Setup each hit region for voting.
- vote.buttonMode = true;
- vote.mouseChildren = false;
- vote.addEventListener( MouseEvent.CLICK, onSetVote );
- vote.addEventListener( MouseEvent.MOUSE_OVER, onVoteOver );
- }
-
- // Called when the mouse exits the voter.
- skin.addEventListener( MouseEvent.MOUSE_OUT, onOut );
- }
- }
-
- // Sets the tag name.
- public function setTag( _tag:String ) {
- tag = _tag;
- }
-
- // Gets a vote from Drupal.
- public function getVote( _nodeId:Number, _cache:Boolean = false )
- {
- // Store the node Id and drupal connection.
- nodeId = _nodeId;
- cache = _cache;
-
- // Get the vote from Drupal.
- var cmd:String = userMode ? Service.GET_USER_VOTE : Service.GET_VOTE;
- Service.call( cmd, onVoteGet, null, "node", nodeId, tag );
- }
-
- // The return function from Drupal.
- private function onVoteGet( vote:Object )
- {
- // Set the selected fill width
- if( vote && selected && selected.fill_mc ) {
- selected.fill_mc.width = vote.value;
- }
-
- dispatchEvent( new DashEvent( DashEvent.VOTE_GET, vote ) );
- }
-
- // Set the selected vote.
- public function setVote( vote:Object )
- {
- // Set the selected fill width
- if( vote && selected && selected.fill_mc ) {
- selected.fill_mc.width = vote.value;
- }
- }
-
- // Called when the user makes a vote.
- private function onSetVote( event:MouseEvent )
- {
- // Get the value of the vote that was clicked.
- voteValue = event.target.name.substr(1);
-
- if( cache ) {
- setVote( {value:voteValue} );
- }
- else {
- processVote();
- }
- }
-
- // Processes the cached vote.
- public function processVote()
- {
- // Check to see if the node Id is valid.
- if( nodeId ) {
-
- // If the vote value is zero then delete the vote.
- if( voteValue == 0 ) {
- dispatchEvent( new DashEvent( DashEvent.PROCESSING ) );
- Service.call( Service.DELETE_VOTE, onVoteDelete, null, "node", nodeId, tag );
- }
- else {
- dispatchEvent( new DashEvent( DashEvent.PROCESSING ) );
- Service.call( Service.SET_VOTE, onVoteSet, null, "node", nodeId, voteValue, tag );
- }
- }
- }
-
- // The return function from Drupal.
- private function onVoteSet( vote:Object )
- {
- // Set the selected fill width
- setVote( {value: (userMode ? voteValue : vote.value)} );
- dispatchEvent( new DashEvent( DashEvent.VOTE_SET, vote ) );
- }
-
- private function onVoteDelete( vote:Object )
- {
- dispatchEvent( new DashEvent( DashEvent.VOTE_DELETE, vote ) );
- }
-
- // Called when the user hovers over a vote.
- private function onVoteOver( event:MouseEvent )
- {
- if( voter && voter.fill_mc ) {
- voter.fill_mc.width = event.target.name.substr(1);
- }
- }
-
- // Called when the user moves his mouse out.
- private function onOut( event:MouseEvent )
- {
- if( voter && voter.fill_mc ) {
- voter.fill_mc.width = 0;
- }
- }
-
- // Declare all of our child movie clips
- public var votes:MovieClip;
- public var selected:MovieClip;
- public var voter:MovieClip;
-
- // Keep track of what mode we are in.
- private var userMode:Boolean;
- private var cache:Boolean;
- private var voteValue:Number;
-
- // Store the node Id and vote tag.
- private var nodeId:Number;
- private var tag:String;
- }
-}
+package com.tmtdigital.dash.display.voter
679 com/tmtdigital/dash/net/Gateway.as
View
@@ -1,678 +1 @@
-/**
- *
- * Gateway.as
- *
- * Description: Class that provides an interface between different components. This class will be used
- * to abstract out all external and internal interface interactions. The external interface
- * is used to connect many different instances of the Dash Media Player on the page at once.
- * This means that you can quite literally have playlists and nodes on the page at a time talking to
- * one another as if they were connected internally.
-
- *
- * Author: Travis Tidwell ( travist@tmtdigital.com )
- *
- **/
-
-package com.tmtdigital.dash.net
-{
- import com.tmtdigital.dash.DashPlayer;
- import com.tmtdigital.dash.display.media.MediaPlayer;
- import com.tmtdigital.dash.utils.Utils;
- import com.tmtdigital.dash.net.Service;
- import com.tmtdigital.dash.config.Params;
-
- import flash.external.*;
- import flash.utils.*;
- import flash.events.*;
- import flash.net.*;
-
- public class Gateway
- {
- /**
- * Load the interface for a connection between multiple instances of the Dash Media Player
- * on the page at a time.
- */
- public static function loadGateway( _onLoaded:Function )
- {
- onLoaded = _onLoaded;
- external = false;
- javaScriptReady = false;
- callbacksAdded = false;
- loaded = false;
-
- // Add all of the connections.
- addConnects();
-
- // Check the interface.
- if( checkInterface() ) {
-
- // Interface is ready.
- onReady();
- }
- else {
- // Start the timer check.
- startTimerCheck();
- }
- }
-
- /**
- * Add all of the connections to the connects array.
- */
- private static function addConnects()
- {
- // Declare a new connects array.
- connects = new Array();
-
- // If they wish to connect to another player.
- if( Params.flashVars.connect ) {
-
- // If they have an "_and_" within their connection, then
- // this means that there are multiple connecions to be made.
- if ( Params.flashVars.connect.indexOf('_and_') >= 0) {
-
- // Set up the connection by spliting the connect string.
- connects = Params.flashVars.connect.split('_and_');
- } else {
-
- // Add our single connection to our array.
- connects.push( Params.flashVars.connect );
- }
- }
- }
-
- /**
- * Checks to see if the interface is available.
- *
- * @return - True (ready), False (not ready)
- */
- private static function checkInterface() : Boolean
- {
- if( Params.flashVars.connect ) {
- // Check the interface.
- if ( ExternalInterface.available ) {
-
- // Add all of the callbacks.
- if( addCallbacks() ) {
-
- // Check the JavaScript.
- if ( isJavaScriptReady() ) {
-
- // We are ready!
- return true;
- }
- }
- }
- }
- else {
- return true;
- }
-
- return false;
- }
-
- /**
- * Called when our system is ready to go...
- */
- private static function onReady()
- {
- // If we want to connect and our java script is ready...
- if( Params.flashVars.connect && javaScriptReady && (Params.flashVars.connect != Params.flashVars.id) ) {
- // We want an external connection.
- external = true;
- // Register for our dash player object.
- ExternalInterface.call("dashRegisterObject", Params.flashVars.id );
- }
- else {
- // Initialize our gateway...
- initialize();
- }
- }
-
- /**
- * Adds all of our ExternalInterface callback routines.
- *
- * @return - True if the callback registration was successful.
- */
- private static function addCallbacks() : Boolean
- {
- // Make sure we have not already added our callbacks.
- if( !callbacksAdded ) {
-
- // Try to register all of our callbacks.
- try {
- // Register for all our callbacks.
- ExternalInterface.addCallback( "initialize", initialize );
- ExternalInterface.addCallback( "spawn", spawn );
- ExternalInterface.addCallback( "loadNode", loadNode );
- ExternalInterface.addCallback( "isNodeLoaded", isNodeLoaded );
- ExternalInterface.addCallback( "loadPlaylist", loadPlaylist );
- ExternalInterface.addCallback( "setPlaylistVote" , setPlaylistVote );
- ExternalInterface.addCallback( "loadPrev", loadPrev );
- ExternalInterface.addCallback( "loadNext", loadNext );
- ExternalInterface.addCallback( "prevPage", prevPage );
- ExternalInterface.addCallback( "nextPage", nextPage );
- ExternalInterface.addCallback( "setFilter", setFilter );
- ExternalInterface.addCallback( "setPlaylist", setPlaylist );
- ExternalInterface.addCallback( "loadMedia", loadMedia );
- ExternalInterface.addCallback( "playMedia", playMedia );
- ExternalInterface.addCallback( "pauseMedia", pauseMedia );
- ExternalInterface.addCallback( "stopMedia", stopMedia );
- ExternalInterface.addCallback( "setSeek", setSeek );
- ExternalInterface.addCallback( "setVolume", setVolume );
- ExternalInterface.addCallback( "getVolume", getVolume );
- ExternalInterface.addCallback( "resetControls", resetControls );
- ExternalInterface.addCallback( "enableControls", enableControls );
- ExternalInterface.addCallback( "setControlState", setControlState );
- ExternalInterface.addCallback( "setControlTime", setControlTime );
- ExternalInterface.addCallback( "setControlVolume", setControlVolume );
- ExternalInterface.addCallback( "setControlProgress", setControlProgress );
- ExternalInterface.addCallback( "setControlSeek", setControlSeek );
- ExternalInterface.addCallback( "controlUpdate", controlUpdate );
- ExternalInterface.addCallback( "setMaximize", setMaximize );
- ExternalInterface.addCallback( "setFullScreen", setFullScreen );
- ExternalInterface.addCallback( "setMenu", setMenu );
- ExternalInterface.addCallback( "showInfo", showInfo );
- ExternalInterface.addCallback( "setSkin", setSkin );
- ExternalInterface.addCallback( "serviceCall", serviceCall );
- callbacksAdded = true;
- } catch (error:SecurityError) {
- trace("A SecurityError occurred: " + error.message + "\n");
- } catch (error:Error) {
- trace("An Error occurred: " + error.message + "\n");
- }
- }
-
- // Return if our callbacks were registered.
- return callbacksAdded;
- }
-
- /**
- * Starts a timer for re-checking the interface to see if it is ready.
- */
- private static function startTimerCheck()
- {
- // Declare the readyTime if we have not already done so.
- if( !readyTimer ) {
- readyTimer = new Timer(200);
- readyTimer.addEventListener(TimerEvent.TIMER, timerHandler);
- }
-
- // Reset our retries and start the counter.
- retries = 0;
- readyTimer.start();
- }
-
- /**
- * Checks to see if javascript is ready to go.
- *
- * @return - True if JavaScript is ready.
- */
- private static function isJavaScriptReady():Boolean
- {
- if( !javaScriptReady )
- {
- // If we wish to connect to external interfaces, then
- // we will need to perform this check. Otherwise, just
- // set the ready flag to true since all communication will
- // be internal.
-
- if( Params.flashVars.connect ) {
- javaScriptReady = ExternalInterface.call("isDashReady");
- }
- else {
- javaScriptReady = true;
- }
- }
-
- return javaScriptReady;
- }
-
- /**
- * Called every timer interval to recheck our external interface.
- *
- * @param - The timer event object.
- */
-
- private static function timerHandler(event:TimerEvent):void
- {
- if( checkInterface() || (retries++ >= 5) ) {
- readyTimer.stop();
- onReady();
- }
- }
-
- /**
- * Called when our JavaScript gateway returns from the registration...
- */
-
- public static function initialize()
- {
- if( !loaded ) {
- loaded = true;
- onLoaded();
- }
- }
-
- /**
- * Spawns a player...
- */
- public static function spawn( callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSpawn", connect );
- }
- } else {
- ExternalInterface.call( "dashSpawnWindow", Params.playerPath );
- }
- }
-
- /**
- * Loads a node
- */
- public static function loadNode( node:* = null, callExternal:Boolean = false )
- {
- if ( callExternal && external && node ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashLoadNode", connect, node.nid );
- }
- } else {
- DashPlayer.loadNode( Params.flashVars.cacheload ? node : node.nid );
- }
- }
-
- public static function playMedia( _file:String = null, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashPlay", connect, _file );
- }
- } else {
- loadMedia( _file );
- DashPlayer.media.playFile();
- }
- }
-
- public static function pauseMedia( callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashPause", connect );
- }
- } else {
- DashPlayer.media.pauseFile();
- }
- }
-
- public static function stopMedia( callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashStop", connect );
- }
- } else {
- DashPlayer.media.stopFile();
- }
- }
-
- public static function setSeek( time:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSeek", connect, time );
- }
- } else {
- DashPlayer.media.setSeek( time );
- }
- }
-
- public static function setVolume( vol:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashVolume", connect, vol );
- }
- } else {
- DashPlayer.media.setVolume( vol );
- }
- }
-
- public static function getVolume( callExternal:Boolean = false ):Number
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- return ExternalInterface.call( "dashGetVolume", connect );
- }
- } else {
- return DashPlayer.media.getVolume();
- }
-
- return 0;
- }
-
- public static function setFullScreen( on:Boolean, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetFullScreen", connect, on );
- }
- } else {
- DashPlayer.toggleFullScreen( on );
- }
- }
-
- public static function setMaximize( max:Boolean, tween:Boolean = true, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetMaximize", connect, max, tween );
- }
- } else {
- DashPlayer.setMaximize( max, tween );
- }
- }
-
- public static function setMenu( on:Boolean, tween:Boolean = true, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetMenu", connect, on, true );
- }
- } else if( DashPlayer.dash.node ) {
- DashPlayer.dash.node.fields.menu.toggleMenuMode( on, tween );
- }
- }
-
- public static function showInfo( on:Boolean, tween:Boolean = true, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashShowInfo", connect, on, true );
- }
- } else if( DashPlayer.dash.node ) {
- DashPlayer.dash.node.fields.showInfo( on, tween );
- }
- }
-
- public static function isNodeLoaded( callExternal:Boolean = false ):Boolean
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- return ExternalInterface.call( "dashIsNodeLoaded", connect );
- }
- } else if( DashPlayer.dash.node ) {
- return DashPlayer.dash.node.loaded;
- }
-
- return false;
- }
-
- public static function resetControls( callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashResetControls", connect );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.reset();
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.reset();
- }
- }
- }
-
- public static function enableControls( enable:Boolean, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashEnableControls", connect, enable );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.enable( enable );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.enable( enable );
- }
- }
- }
-
- public static function setControlState( state:String, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetControlState", connect, state );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.setState( state );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.setState( state );
- }
- }
- }
-
- public static function setControlTime( time:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetControlTime", connect, time );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.setTotalTime( time );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.setTotalTime( time );
- }
- }
- }
-
- public static function setControlVolume( vol:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetControlVolume", connect, vol );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.setVolume( vol );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.setVolume( vol );
- }
- }
- }
-
- public static function setControlProgress( progress:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetControlProgress", connect, progress );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.setProgress( progress );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.setProgress( progress );
- }
- }
- }
-
- public static function setControlSeek( seek:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetControlSeek", connect, seek );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.setSeekValue( seek );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.setSeekValue( seek );
- }
- }
- }
-
- public static function controlUpdate( playTime:Number, totalTime:Number, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashControlUpdate", connect, playTime, totalTime );
- }
- } else {
- if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.media ) {
- DashPlayer.dash.playlist.media.controlBar.update( playTime, totalTime );
- }
-
- if( DashPlayer.dash.node && DashPlayer.dash.node.fields && DashPlayer.dash.node.fields.media ) {
- DashPlayer.dash.node.fields.media.controlBar.update( playTime, totalTime );
- }
- }
- }
-
- public static function setPlaylistVote( nodeId:Number, vote:Object, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetPlaylistVote", connect, nodeId, vote );
- }
- } else if( DashPlayer.dash.playlist ) {
- DashPlayer.dash.playlist.setVote( nodeId, vote );
- }
- }
-
- public static function loadPlaylist( playlistName:String = null, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashLoadPlaylist", connect, playlistName );
- }
- } else if( DashPlayer.dash.playlist ) {
- DashPlayer.dash.playlist.loadPlaylist( playlistName );
- }
- }
-
- public static function loadPrev( loop:Boolean = false, playAfter:Boolean = false, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashLoadPrev", connect, loop, playAfter );
- }
- } else if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.pager ) {
- DashPlayer.dash.playlist.pager.loadPrev( playAfter );
- }
- }
-
- public static function loadNext( loop:Boolean = false, playAfter:Boolean = false, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashLoadNext", connect, loop, playAfter );
- }
- } else if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.pager ) {
- DashPlayer.dash.playlist.pager.loadNext( playAfter );
- }
- }
-
- public static function prevPage( loop:Boolean = false, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashPrevPage", connect, loop );
- }
- } else if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.pager ) {
- DashPlayer.dash.playlist.pager.prevPage();
- }
- }
-
- public static function nextPage( loop:Boolean = false, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashNextPage", connect, loop );
- }
- } else if( DashPlayer.dash.playlist && DashPlayer.dash.playlist.pager ) {
- DashPlayer.dash.playlist.pager.nextPage();
- }
- }
-
- public static function setFilter( argument:String, index:Number = 0, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetFilter", connect, argument, index );
- }
- } else if( DashPlayer.dash.playlist ) {
- DashPlayer.dash.playlist.setFilter( argument, index );
- }
- }
-
- public static function setPlaylist( message:Object, callExternal:Boolean = false )
- {
- if ( callExternal && external ) {
- for each (var connect:String in connects) {
- ExternalInterface.call( "dashSetPlaylist", connect, message );
- }
- } else if( DashPlayer.dash.playlist ) {
- DashPlayer.dash.playlist.setPlaylist( message );
- }
- }
-
- private static function loadMedia( _file:String ):void
- {
- if ( _file ) {
- DashPlayer.media.initialize();
- DashPlayer.media.loadMediaFile( Utils.getMediaFile( {path:_file} ) );
- }
- }
-
- private static function setSkin( skinName:String ):void
- {
- DashPlayer.setSkin( skinName );
- }
-
- private static function serviceCall( command:String, arguments:Array ):void
- {
- if ( Params.flashVars.externalservice ) {
- var message:Object = new Object();
- message.command = command;
- message.onSuccess = onSuccess;
- message.onFailed = null;
- message.args = arguments;
- Service.serviceCall( message );
- }
- }
-
- public static function debug( arg:String )
- {
- ExternalInterface.call( "dashDebug", arg );
- }
-
- private static function onSuccess( ... args )
- {
- ExternalInterface.call( "dashServiceReturn", args );
- }
-
- private static var callbacksAdded:Boolean;
- private static var javaScriptReady:Boolean;
- private static var external:Boolean;
- private static var readyTimer:Timer;
- private static var retries:uint;
- private static var onLoaded:Function;
- private static var loaded:Boolean;
- private static var connects:Array;
- }
-}
+/**
2  dashPlayer.js
View
@@ -1 +1 @@
-var dashReady=false;var dashObjects=new Array();var dashCallback=function(args){};var dashId="dashplayer";$(document).ready(function(){dashReady=true});function isDashReady(){return dashReady};function dashDebug(arg){$('#dashdebug').append(arg+"<br/>")};function getDashObject(dashId){var dashObj=null;if(dashObjects[dashId]){if(dashObjects[dashId].object){dashObj=dashObjects[dashId].object}}if(!dashObj){if(dashReady){if(navigator.appName.indexOf("Microsoft")!=-1){dashObj=window[dashId]}else{if(document[dashId].length!==undefined){dashObj=document[dashId][1]}else{dashObj=document[dashId]}}if(dashObjects[dashId]){dashObjects[dashId].object=dashObj}}}return dashObj};function dashAddObject(dashId){dashObjects[dashId]={id:dashId,ready:false,object:null}};function isDashRegistered(){var registered=true;if(dashObjects){for(var dashId in dashObjects){if(dashObjects.hasOwnProperty(dashId)){registered&=dashObjects[dashId].ready}}}return registered};function dashInitialize(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.initialize()}catch(error){dashDebug(error)}}};function startDash(){if(isDashRegistered()){for(var dashId in dashObjects){if(dashObjects.hasOwnProperty(dashId)){dashInitialize(dashId)}}}};function dashRegisterObject(dashId){if(!dashObjects.hasOwnProperty(dashId)){dashAddObject(dashId)}dashObjects[dashId].ready=true;startDash()};function dashSpawn(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.spawn()}catch(error){dashDebug(error)}return true}return false};function dashSpawnWindow(playerPath){try{window.open(playerPath)}catch(error){dashDebug(error)}};function dashLoadNode(dashId,nodeId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadNode(nodeId)}catch(error){dashDebug(error)}return true}return false};function dashLoad(dashId,file){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.load(file)}catch(error){dashDebug(error)}return true}return false};function dashPlay(dashId,file){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.playMedia(file)}catch(error){dashDebug(error)}return true}return false};function dashPause(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.pauseMedia()}catch(error){dashDebug(error)}return true}return false};function dashStop(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.stopMedia()}catch(error){dashDebug(error)}return true}return false};function dashSeek(dashId,seekTime){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setSeek(seekTime)}catch(error){dashDebug(error)}return true}return false};function dashVolume(dashId,vol){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setVolume(vol)}catch(error){dashDebug(error)}return true}return false};function dashGetVolume(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{return dashObj.getVolume()}catch(error){dashDebug(error)}}return 0};function dashSetFullScreen(dashId,full){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setFullScreen(full)}catch(error){dashDebug(error)}return true}return false};function dashSetMaximize(dashId,max,tween){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setMaximize(max,tween)}catch(error){dashDebug(error)}return true}return false};function dashSetMenu(dashId,menu,tween){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setMenu(menu,tween)}catch(error){dashDebug(error)}return true}return false};function dashIsNodeLoaded(dashId){var dashObj=getDashObject(dashId);if(dashObj){return(dashObj.isNodeLoaded())}return false};function dashLoadPlaylist(dashId,playlist){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadPlaylist(playlist)}catch(error){dashDebug(error)}return true}return false};function dashLoadPrev(dashId,loop,playAfter){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadPrev(loop,playAfter)}catch(error){dashDebug(error)}return true}return false};function dashLoadNext(dashId,loop,playAfter){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadNext(loop,playAfter)}catch(error){dashDebug(error)}return true}return false};function dashPrevPage(dashId,loop){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.prevPage(loop)}catch(error){dashDebug(error)}return true}return false};function dashNextPage(dashId,loop){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.nextPage(loop)}catch(error){dashDebug(error)}return true}return false};function dashSetFilter(dashId,argument,index){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setFilter(argument,index)}catch(error){dashDebug(error)}return true}return false};function dashSetPlaylist(dashId,message){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setPlaylist(message)}catch(error){dashDebug(error)}return true}return false};function dashResetControls(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.resetControls();return true}return false};function dashEnableControls(dashId,enable){var dashObj=getDashObject(dashId);if(dashObj){dashObj.enableControls(enable);return true}return false};function dashSetControlState(dashId,state){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlState(state);return true}return false};function dashSetControlTime(dashId,time){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlTime(time);return true}return false};function dashSetControlVolume(dashId,volume){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlVolume(volume);return true}return false};function dashSetControlProgress(dashId,progress){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlProgress(progress);return true}return false};function dashSetControlSeek(dashId,seek){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlSeek(seek);return true}return false};function dashControlUpdate(dashId,playTime,totalTime){var dashObj=getDashObject(dashId);if(dashObj){dashObj.controlUpdate(playTime,totalTime);return true}return false};function dashSetSkin(dashId,skin){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setSkin(skin);return true}return false};function dashServiceCall(){var dashId=arguments[0];arguments.shift();var command=arguments[0];arguments.shift();dashCallback=arguments[0];arguments.shift();var dashObj=getDashObject(dashId);if(dashObj){dashObj.serviceCall(command,arguments);return true}return false};function dashServiceReturn(args){dashCallback(args)};function onYouTubePlayerReady(playerId){dashId=playerId;var dashObj=getDashObject(playerId);if(dashObj){try{dashObj.addEventListener("onStateChange","youTubeOnStateChange");dashObj.addEventListener("onError","youTubeOnError");dashObj.onYouTubeReady()}catch(error){dashDebug(error)}}};function youTubeOnStateChange(newState){var dashObj=getDashObject(dashId);if(dashObj){dashObj.onYouTubeStateChange(newState)}};function youTubeOnError(error){var dashObj=getDashObject(dashId);if(dashObj){dashObj.onYouTubeError(error)}};function youTubeLoad(dashId,youTubeId,startSeconds){var dashObj=getDashObject(dashId);if(dashObj){dashObj.loadVideoById(youTubeId,startSeconds)}};function youTubeCue(dashId,youTubeId,startSeconds){var dashObj=getDashObject(dashId);if(dashObj){dashObj.cueVideoById(youTubeId,startSeconds)}};function youTubeDestroy(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.destroy()}};function youTubeClear(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.clearVideo()}};function youTubeSetSize(dashId,_width,_height){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setSize(_width,_height)}};function youTubePlay(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.playVideo()}};function youTubePause(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.pauseVideo()}};function youTubeStop(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.stopVideo()}};function youTubeSeek(dashId,seconds,allowSeekAhead){var dashObj=getDashObject(dashId);if(dashObj){dashObj.seekTo(seconds,allowSeekAhead)}};function youTubeGetBytesLoaded(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoBytesLoaded()}return 0};function youTubeGetBytesTotal(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoBytesTotal()}return 0};function youTubeGetCurrentTime(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getCurrentTime()}return 0};function youTubeGetDuration(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getDuration()}return 0};function youTubeSetVolume(dashId,newVolume){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setVolume(newVolume)}};function youTubeGetVolume(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVolume()}return 0};function youTubeGetEmbedCode(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getEmbedCode()}return""};function youTubeGetVideoUrl(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoUrl()}return""};
+var dashReady=false;var dashObjects=new Array();var dashCallback=function(args){};var dashId="dashplayer";$(document).ready(function(){dashReady=true});function isDashReady(){return dashReady};function dashDebug(arg){$('#dashdebug').append(arg+"<br/>")};function getDashObject(dashId){var dashObj=null;if(dashObjects[dashId]){if(dashObjects[dashId].object){dashObj=dashObjects[dashId].object}}if(!dashObj){if(dashReady){if(navigator.appName.indexOf("Microsoft")!=-1){dashObj=window[dashId]}else{if(document[dashId].length!==undefined){dashObj=document[dashId][1]}else{dashObj=document[dashId]}}if(dashObjects[dashId]){dashObjects[dashId].object=dashObj}}}return dashObj};function dashAddObject(dashId){dashObjects[dashId]={id:dashId,ready:false,object:null}};function isDashRegistered(){var registered=true;if(dashObjects){for(var dashId in dashObjects){if(dashObjects.hasOwnProperty(dashId)){registered&=dashObjects[dashId].ready}}}return registered};function dashInitialize(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.initialize()}catch(error){dashDebug(error)}}};function startDash(){if(isDashRegistered()){for(var dashId in dashObjects){if(dashObjects.hasOwnProperty(dashId)){dashInitialize(dashId)}}}};function dashRegisterObject(dashId){if(!dashObjects.hasOwnProperty(dashId)){dashAddObject(dashId)}dashObjects[dashId].ready=true;startDash()};function dashSpawn(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.spawn()}catch(error){dashDebug(error)}return true}return false};function dashSpawnWindow(playerPath){try{window.open(playerPath)}catch(error){dashDebug(error)}};function dashLoadNode(dashId,nodeId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadNode(nodeId)}catch(error){dashDebug(error)}return true}return false};function dashLoad(dashId,file){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadMedia(file)}catch(error){dashDebug(error)}return true}return false};function dashPlay(dashId,file){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.playMedia(file)}catch(error){dashDebug(error)}return true}return false};function dashPause(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.pauseMedia()}catch(error){dashDebug(error)}return true}return false};function dashStop(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.stopMedia()}catch(error){dashDebug(error)}return true}return false};function dashSeek(dashId,seekTime){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setSeek(seekTime)}catch(error){dashDebug(error)}return true}return false};function dashVolume(dashId,vol){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setVolume(vol)}catch(error){dashDebug(error)}return true}return false};function dashGetVolume(dashId){var dashObj=getDashObject(dashId);if(dashObj){try{return dashObj.getVolume()}catch(error){dashDebug(error)}}return 0};function dashSetFullScreen(dashId,full){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setFullScreen(full)}catch(error){dashDebug(error)}return true}return false};function dashSetMaximize(dashId,max,tween){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setMaximize(max,tween)}catch(error){dashDebug(error)}return true}return false};function dashSetMenu(dashId,menu,tween){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setMenu(menu,tween)}catch(error){dashDebug(error)}return true}return false};function dashIsNodeLoaded(dashId){var dashObj=getDashObject(dashId);if(dashObj){return(dashObj.isNodeLoaded())}return false};function dashLoadPlaylist(dashId,playlist){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadPlaylist(playlist)}catch(error){dashDebug(error)}return true}return false};function dashLoadPrev(dashId,loop,playAfter){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadPrev(loop,playAfter)}catch(error){dashDebug(error)}return true}return false};function dashLoadNext(dashId,loop,playAfter){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.loadNext(loop,playAfter)}catch(error){dashDebug(error)}return true}return false};function dashPrevPage(dashId,loop){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.prevPage(loop)}catch(error){dashDebug(error)}return true}return false};function dashNextPage(dashId,loop){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.nextPage(loop)}catch(error){dashDebug(error)}return true}return false};function dashSetFilter(dashId,argument,index){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setFilter(argument,index)}catch(error){dashDebug(error)}return true}return false};function dashSetPlaylist(dashId,message){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setPlaylist(message)}catch(error){dashDebug(error)}return true}return false};function dashSetPlaylistVote(dashId,nodeId,vote){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setPlaylistVote(nodeId,vote)}catch(error){dashDebug(error)}return true}return false};function dashSetVote(dashId,vote){var dashObj=getDashObject(dashId);if(dashObj){try{dashObj.setVote(vote)}catch(error){dashDebug(error)}return true}return false};function dashResetControls(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.resetControls();return true}return false};function dashEnableControls(dashId,enable){var dashObj=getDashObject(dashId);if(dashObj){dashObj.enableControls(enable);return true}return false};function dashSetControlState(dashId,state){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlState(state);return true}return false};function dashSetControlTime(dashId,time){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlTime(time);return true}return false};function dashSetControlVolume(dashId,volume){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlVolume(volume);return true}return false};function dashSetControlProgress(dashId,progress){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlProgress(progress);return true}return false};function dashSetControlSeek(dashId,seek){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setControlSeek(seek);return true}return false};function dashControlUpdate(dashId,playTime,totalTime){var dashObj=getDashObject(dashId);if(dashObj){dashObj.controlUpdate(playTime,totalTime);return true}return false};function dashSetSkin(dashId,skin){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setSkin(skin);return true}return false};function dashServiceCall(){var dashId=arguments[0];arguments.shift();var command=arguments[0];arguments.shift();dashCallback=arguments[0];arguments.shift();var dashObj=getDashObject(dashId);if(dashObj){dashObj.serviceCall(command,arguments);return true}return false};function dashServiceReturn(args){dashCallback(args)};function onYouTubePlayerReady(playerId){dashId=playerId;var dashObj=getDashObject(playerId);if(dashObj){try{dashObj.addEventListener("onStateChange","youTubeOnStateChange");dashObj.addEventListener("onError","youTubeOnError");dashObj.onYouTubeReady()}catch(error){dashDebug(error)}}};function youTubeOnStateChange(newState){var dashObj=getDashObject(dashId);if(dashObj){dashObj.onYouTubeStateChange(newState)}};function youTubeOnError(error){var dashObj=getDashObject(dashId);if(dashObj){dashObj.onYouTubeError(error)}};function youTubeLoad(dashId,youTubeId,startSeconds){var dashObj=getDashObject(dashId);if(dashObj){dashObj.loadVideoById(youTubeId,startSeconds)}};function youTubeCue(dashId,youTubeId,startSeconds){var dashObj=getDashObject(dashId);if(dashObj){dashObj.cueVideoById(youTubeId,startSeconds)}};function youTubeDestroy(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.destroy()}};function youTubeClear(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.clearVideo()}};function youTubeSetSize(dashId,_width,_height){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setSize(_width,_height)}};function youTubePlay(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.playVideo()}};function youTubePause(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.pauseVideo()}};function youTubeStop(dashId){var dashObj=getDashObject(dashId);if(dashObj){dashObj.stopVideo()}};function youTubeSeek(dashId,seconds,allowSeekAhead){var dashObj=getDashObject(dashId);if(dashObj){dashObj.seekTo(seconds,allowSeekAhead)}};function youTubeGetBytesLoaded(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoBytesLoaded()}return 0};function youTubeGetBytesTotal(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoBytesTotal()}return 0};function youTubeGetCurrentTime(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getCurrentTime()}return 0};function youTubeGetDuration(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getDuration()}return 0};function youTubeSetVolume(dashId,newVolume){var dashObj=getDashObject(dashId);if(dashObj){dashObj.setVolume(newVolume)}};function youTubeGetVolume(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVolume()}return 0};function youTubeGetEmbedCode(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getEmbedCode()}return""};function youTubeGetVideoUrl(dashId){var dashObj=getDashObject(dashId);if(dashObj){return dashObj.getVideoUrl()}return""};
38 dashPlayerFull.js
View
@@ -537,6 +537,44 @@ function dashSetPlaylist( dashId, message ) {
};
/**
+ * Sets the vote of the playlist.
+ *
+ * @param - The ID of the player you would like to send this request too.
+ * @param - The message object that you would like to use to provide to the playlist.
+ */
+function dashSetPlaylistVote( dashId, nodeId, vote ) {
+ var dashObj = getDashObject( dashId );
+ if( dashObj ) {
+ try {
+ dashObj.setPlaylistVote( nodeId, vote );
+ } catch( error ) {
+ dashDebug( error );
+ }
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Sets the vote of the node.
+ *
+ * @param - The ID of the player you would like to send this request too.
+ * @param - The message object that you would like to use to provide to the playlist.
+ */
+function dashSetVote( dashId, vote ) {
+ var dashObj = getDashObject( dashId );
+ if( dashObj ) {
+ try {
+ dashObj.setVote( vote );
+ } catch( error ) {
+ dashDebug( error );
+ }
+ return true;
+ }
+ return false;
+};
+
+/**
* Resets the controls.
*
* @param - The ID of the player you would like to send this request too.
Please sign in to comment.
Something went wrong with that request. Please try again.