Referencing your media player object in code.
Before you read this article, it is important that you first take a look at the prerequisites
Every time that the media player is added to a page, it adds it to the global jQuery.media.players associative array. This behavior works a little different depending on whether you are inside of a CMS vs. using the PHP wrapper outside of a CMS. Please follow the guide that pertains to your use case.
Using the PHP wrapper ( outside of a CMS )
The default key for your player is player where you can then reference the default media player object by using jQuery.media.players.player. This can be changed easily by calling the setId function within the PHP wrapper for the media player. For example...
To reference the default media player
<?php
// Include the OSMPlayer.php file.
include('OSMPlayer.php');
// Create the OSMPlayer.
$player = new OSMPlayer( array(
'playlist' => 'playlist.xml'
));
// Print out the OSMPlayer code.
print $player->getPlayer();
?>
<script type="text/javascript">
// Now we can reference the default player.
var player = jQuery.media.players.player;
</script>To reference another media player
<?php
// Include the OSMPlayer.php file.
include('OSMPlayer.php');
// Create the OSMPlayer.
$player = new OSMPlayer( array(
'playlist' => 'playlist.xml'
));
// Set the player Id.
$player->setId('myplayer');
// Print out the OSMPlayer code.
print $player->getPlayer();
?>
<script type="text/javascript">
// Now we can reference the myplayer player.
var player = jQuery.media.players.myplayer;
</script>Inside of a CMS like Drupal.
Inside a CMS, however, the default key is denoted by mediafront_{preset_name} where the {preset_name} is replaced by the name of the preset that was created within the CMS. For example, to locate the name of a media player on your page that was given a preset name of player you would add the following to your javascript.
<script type="text/javascript">
// Reference the medafront_player object.
var player = jQuery.media.players.mediafront_player;
</script>


