setLinkHandler

 

When a user clicks on the info icon within a playlist, default functionality will be forked to the function you specify.

This feature was designed to allow advanced developers to control what happens when the link icon is clicked. When using this feature, normal link functionality will NOT initiate, instead, you'll be responsible for determining what happens when the link icon is clicked.

The function you specify should be set up to receive one argument. The value of the argument will be a Track Dataset, which will include all the info originally establsihed in the playlist.

An associated Event Listener "link" is also available, which compliments this feature. While this "setLinkHandler" is a blocking situation (default behaviour is cancelled), the "link" Event Listener, is non-blocking, meaning that Wimpy deals with the link normally, but also sends notifications similar to this.

setLinkHandler(theFunc)

 

Parameters

theFunc function

A function that will get "pinged" when a link request is initiated.

 

 

Return Value

none

 

See Also

 

Examples

Example 1
<!-- Create a player instance on the page -->
<div id="myPlayerID" data-wimpyplayer data-linkEnable></div>

<script>
// Set up a handler function.
// Wimpy pings this function with one argument, which is a "Track Dataset"
// From here, you can do whatever you want with the request.
function myLinkHandler(trackInfo){
		var retval = "";
		for(var prop in trackInfo){
			retval += prop + " " + trackInfo[prop] + "\n";
		}
		alert(retval);
}

// Set up the "myPlayer" variable on the window scope
var myPlayer;

// Create a function to send to wimpy, which will get pinged when all players are set up
function setupLinkHandler(){
	// Get a handle to the player instance.
	myPlayer = wimpy.getPlayer("myPlayerID");
	
	// And finally set up the link handler on the player
	myPlayer.setLinkHandler(myLinkHandler);
}

// We need to wait until the player is set up before we can apply the link handler.
wimpy.onReady(setupLinkHandler);

</script>

 

Example 4

Another approach to set up the link handler

<!-- Create a player instance on the page -->
<div id="myPlayerID" data-wimpyplayer data-linkEnable></div>

<script>
// Set up a handler function.
// Wimpy pings this function with one argument, which is a "Track Dataset"
// From here, you can do whatever you want with the request.
function myLinkHandler(trackInfo){
		var retval = "";
		for(var prop in trackInfo){
			retval += prop + " " + trackInfo[prop] + "\n";
		}
		alert(retval);
}

// Wait until player is ready, and do everything like the first example, but do it all in one line.
wimpy.onReady((function (){
wimpy.getPlayer("myPlayerID").setLinkHandler(myLinkHandler);
}));

</script>

 

Example 3

When setting up a player via javascript, we have access tot he player "handle" right away:

<script>

// Set up a function to "ping" when the link icon is clicked in the playlist.
function myLinkHandler(itemData){
	
	var see = "";
	// Set the playlist
	for(var prop in itemData){
		see += prop + " : " + itemData[prop] + "<br>";
	}
	
	var outputObj = document.getElementById("output");
	outputObj.innerHTML = see;
	
}

// Create a new player
var player = new wimpyPlayer({
		linkEnable : 1
	});


// Setting the "setLinkHandler" to the "myLinkHandler" function.
player.setLinkHandler(myLinkHandler);

</script>