Example 6

This example shows how you can interact with Wimpy.

You need to upgrade your Flash Player

 

 

Returned Data :

Track Info will display here

- a Ask if Wimpy is ready
- Play Track 2
- Get info on the second track in the playlist.
- Call multiple functions at the same time. (Clear playlist, then add new items)

- Get playhead position in seconds
- Get playhead position in percent complete
- Set playhead position to 5 seconds
- Set playhead position to 35 percent complete
- Get load percent
- Get load state
- Get player state
- Get total playlist items
- Get playlist
- Set volume to 40 percent : 100 percent
- Turn Loop Track: "on" : "off"
- Turn Random Playback "on" : "off"
- Turn Repeat Playlist: "on" : "off"
- Turn Mute: "on" : "off"
- Update Artist and Title

Source Code

The following lines are traditionally written in the <head> of the page. NOTE: Although it is not required that these lines appear between the opening <head> and closing </head>, they may also appear in the <body>, however, if these lines do appear in the <body> they must be written above any code that executes any function contained in the external file.

<!-- NOTE: The "rave_js_examples.js" file contains functions to write returned data onto this page.-->
<script language='javascript' src='rave_js_examples.js'></script>
<!-- NOTE: We've externalized the playlist data for the "Add Multiple Tracks" links. -->
<script language='javascript' src='rave_js_example_javascript_playlists.js'></script>
<script language='javascript' src='rave.js'></script>

The following goes into the <body>

<div id="flashcontent">You need to upgrade your Flash Player</div>
<script language="JavaScript" >

function callMultipleFunctions(){
   wimpy_clearPlaylist();
   // addFilesC is located in the external javascript file "rave_js_example_javascript_playlists.js" which was loaded in the <head> tag.
   wimpy_appendPlaylist(addFilesC, true);
   wimpy_appendPlaylist(addFilesC, true);
}

// Setting this to TRUE allows us to receive notifications from Wimpy:
enableWimpyEvents = true;

// Create a new object (can be any name) and add options to it:
var myConfigs = new Object();
myConfigs.wimpyApp = "playlist1.xml";
myConfigs.wimpySkin = "skins/skin_js_examples.xml";
myConfigs.wimpyWidth = "330";
myConfigs.wimpyHeight = "410";

// Render the player and include the config object as the argument:
makeWimpyPlayer(myConfigs);


</script>

The following lines are used to interact with the player:

<a href="javascript:;" onClick="displayInfo(wimpy_amReady_ask())">
- a Ask if Wimpy is ready
</a>

<a href="javascript:;" onClick="displayObject(wimpy_gotoTrack(2))">
- Play Track 2
</a>

<a href="javascript:;" onClick="displayObject(wimpy_getTrackInfo(2))">
- Get info on the second track in the playlist.
</a>

<a href="javascript:;" onClick="callMultipleFunctions()">
- Call multiple functions at the same time. (Clear playlist, then add new items)
</a>

<a href="javascript:;" onClick="displayInfo(wimpy_getPlayheadSeconds())">
- Get playhead position in seconds
</a>

<a href="javascript:;" onClick="displayInfo(wimpy_getPlayheadPercent())">
- Get playhead position in percent complete
</a>

<a href="javascript:;" onClick="wimpy_setPlayheadSeconds(5)">
- <b>Set</b> playhead position to 5 seconds
</a>

<a href="javascript:;" onClick="wimpy_setPlayheadPercent(35)">
- <b>Set</b> playhead position to 35 percent complete
</a>

<a href="javascript:;" onClick="displayInfo(wimpy_getLoadPercent())">
- Get load percent
</a>

<a href="javascript:;" onClick="displayObject(wimpy_getLoadState())">
- Get load state
</a>

<a href="javascript:;" onClick="displayObject(wimpy_getPlayerState())">
- Get player state
</a>

<a href="javascript:;" onClick="displayInfo(wimpy_getTotalPlaylistItems())">
- Get total playlist items
</a>

<a href="javascript:;" onClick="displayPlaylistObject(wimpy_getPlaylist())">
- Get playlist
</a>

- Set volume to
<a href="javascript:;" onClick="wimpy_setVolume(40)">
40 percent
</a> :
<a href="javascript:;" onClick="wimpy_setVolume(100)">
100 percent
</a>

<!-- NOTE: Notice we are using double quotes around the function and single quotes within the arguments -->

- Turn Loop Track:
<a href="javascript:;" onClick="wimpy_setLoopTrackState('on')">
on
</a> :
<a href="javascript:;" onClick="wimpy_setLoopTrackState('off')">
off
</a>

- Turn Random Playback
<a href="javascript:;" onClick="wimpy_setRandomState('on')">
on
</a> :
<a href="javascript:;" onClick="wimpy_setRandomState('off')">
off
</a>

- Turn Repeat Playlist:
<a href="javascript:;" onClick="wimpy_setRepeatState('on')">
on
</a> :
<a href="javascript:;" onClick="wimpy_setRepeatState('off')">
off
</a>

- Turn Mute:
<a href="javascript:;" onClick="wimpy_setMuteState('on')">
on
</a> :
<a href="javascript:;" onClick="wimpy_setMuteState('off')">
off
</a>

<!-- NOTE: Notice we are using single quotes around the function and double quotes within the arguments -->
<!-- NOTE: Yes, we flip-flopped single and double from the previous examples above, just to show you you can do it either way.-->

<a href="javascript:;" onclick='wimpy_updateInfoDisplay("My New Artist", "My New Title")'>
- Update Artist and Title
</a>

 

 

 

 

Part of the Wimpy Rave documentation.
©2009 Plaino