On Track Complete

onTrackComplete -- Establishes the action to occur when a track is finished playing
onTrackCompleteURL -- Sets the URL to go to or the location of the file to load

 

Description

On Track Complete offers two options that determine what the user will experience when a track finishes playing -- "Load Movie" and "Go to URL." onTrackComplete operates in conjunction with onTrackCompleteURL, where onTrackCompleteURL designates the URL to a file that should be loaded, or a URL to a web page to "go to" when the track is finished playing.

This option is completely separate from the built-in JavaScript "trackDone" option. The JavaScript "trackDone" option silently pings a javascript function when a track is finished playing. "On Track Complete" is the visible partner to the JavaScript trackDone feature. "On Track Complete" allows you to do one of the following things once a track is complete:

Go to URL
Wimpy will open a new browser window using the URL specified in onTrackCompleteURL. If you would like to specify a particular window to target, set the linkToWindow option to your designated window name.

Load Movie / Image
The SWF, PNG or JPG image specified for onTrackCompleteURL will load into the Video Window and replace the current video or cover art graphic.

This feature is useful if you would like to load an an alternate movie (SWF) that engages the user with a questionnaire about the track they just viewed or heard. This behavior would be similar to the way youtube.com loads an interactive "trailer" after each movie, which asks the user if they would like to view a similar video.

Another useful interactive "trailer" would be to load a small questionnaire asking the user to vote for the track, replay or go to the next track.

Click here to see a see and download a working onTrackComplete (Load Movie) example.

Once the first frame of the loaded SWF movie (or "trailer") is ready, Wimpy will "shake hands" with the loaded movie by calling a pre-defined function in the loaded movie named "initialize." This means that the loaded movie must have a function named "initialize" in it -- so that the two movies can exchange information. Wimpy will include an argument when it pings the "initialize" in the function. The argument will be an object that contains information about the current track. Pinging the initialize function allows Wimpy and the loaded clip to "shake hands."

Here is a step-by-step account of how Wimpy and the loaded clip interact.

1. Wimpy finishes playing a track.

2. Wimpy loads the "trailer" into the Video Window.

For explanation purposes, we'll say that the loaded clip's file name is ""trailer.swf."

Code-wise it would look something like:

// Wimpy creates a new object to load the SWF in to:
trackDoneMC = new Object();

// Wimpy loads the "trailer.swf" file into the newly created object:
wimpy.loadClip(trackDoneMC, "trailer.swf");

3. Wimpy creates an object that contains information about the current track so that the information can be passed to the loaded "trailer.swf"

So for example, if your XML playlist reads as follows:

<playlist>
  <item>
    <title>       My Title         </title>
    <artist>      My Artist        </artist>
    <album>       My Album         </album>
    <description> My Description   </description>
    <link>        http://www/path/to/page.html   </link>
    <image>       http://www/path/to/image.jpg   </image>
    <id>          12345            </id>
    <whatever>    abcdefg          </whatever>
  </item>
</playlist>

Then Wimpy will create an object that contains information about the track as follows::

var trackObject = new Object();
trackObject.title = "My Title";
trackObject.artist = "My Artist";
trackObject.album = "My Album";
trackObject.description = "My Description";
trackObject.link = "http://www/path/to/page.html";
trackObject.image = "http://www/path/to/image.jpg";
trackObject.id = "12345";
trackObject.whatever = "abcdefg";

 

4. When the first frame of "trailer.swf" is ready, Wimpy will issue a call to the "initialize" function and include the trackObject as the argument.

wimpy.trackDoneMC.initialize(trackObject)

 

5. Therefore, in your "trailer.swf" movie, you should have a function named "initialize" that can accept an object that contains track information.

The track's object will contain simple variables named in accordance with the XML layout of each item. Wimpy will include all of the information that was originally loaded via XML. This means you can put extra <tags>  into each <item> as needed -- Wimpy will send everything that is available in the original playlist.

Here's an example "initialize" function that you can place into your movie that will accept the trackObject and convert each variable in the object to a variable on your loaded movie's main stage. Once the variables have been converted, the movie will advance to the next frame:

stop();
function initialize(theObject){
   for (var prop in theObject){
     this[prop] = theObject[prop];
   }
   play();
}

 

Movies loaded in through onTrackComplete can control Wimpy by tapping into the Wimpy JavaScript Controls (WJC). WJC's can be referenced using either _root or _parent._parent._parent

Example:

_root.js_wimpy_play();
_root.js_wimpy_stop();

OR

_parent._parent._parent.js_wimpy_play();
_parent._parent._parent.js_wimpy_stop();

Click here for a complete list and explanation of the available controls.

 

Options

onTrackComplete
loadClip -- tells Wimpy to load a file into the Video Window
gotoURL -- Tells Wimpy to open a new browser window

onTrackCompleteURL
[ URL ] --
Defines the URL to the file or page.

 

 

Usage

As HTML option:

wimpy.swf?onTrackComplete=gotoURL
wimpy.swf?onTrackCompleteURL=http://www/path/to/file.html

As Wimpy Configs Option:

<onTrackComplete>loadClip</onTrackComplete>
<onTrackCompleteURL>http://www/path/to/file.swf</onTrackCompleteURL>

As Javascript Option:

wimpyConfigs.onTrackComplete="loadClip";
wimpyConfigs.onTrackCompleteURL="http://www/path/to/file.swf";

 

 

Wimpy Player Documentation
Copyright ©2002-2008 Plaino LLC. All rights reserved.
Use of this website signifies your agreement to the Terms of Use.