function hook_swftools_playlist_PLAYER in SWF Tools 6.3
Processes a playlist ready for use by the specified player.
If a player can process a playlist then it should implement this hook to perform processing that turns the SWF Tools array of data in to the format that the player will ultimately use.
If the player uses xml based playlists then this hook should return a string of markup. SWF Tools will take care of storing the playlist and giving it a file name. The filename will be available on the ['othervars']['file_url'] key when the player is ready to be rendered. The filename is a 32 character hexadecimal string that is built by hashing the playlist with the specified player options. This should generate a unique string for a given playlist in a given player. Playlists are not physically written to the file system but are stored in the table {cache_swftools}. All the player needs to do is assign the ['othervars']['url'] value to access it. What actually happens is that SWF Tools is providing a menu path. When the browser requests the file SWF Tools serves it directly from the cache. When the site caches are flushed SWF Tools will rebuild the playlists when they are next requested.
Players such as FlowPlayer 3 do not use an xml based playlist system. Instead they use a configuration array that is written out directly as part of the player configuration. In these cases the processing does not necessarily have to be done in hook_swftools_playlist_PLAYER() and it could be handled in hook_swftools_preprocess_PLAYER(). However, it is a good idea to use the playlist hook as it separates the logic of preparing a playlist from the logic of outputting the player. When preparing a non-xml playlist the code in this hook should directly modify $data, and it should return the value SWFTOOLS_NON_XML_PLAYLIST to notify SWF Tools that xml generation should be skipped.
For examples of xml based playlist generation see:
- swftools_wijering4_swftools_playlist_jwplayer4()
- swftools_simpleviewer_swftools_playlist_simpleviewer()
For examples of non-xml based playlist generation see:
Parameters
array $data: An array of SWF Tools data representing the media that is to be rendered.
See also
hook_swftools_preprocess_PLAYER()
Related topics
10 functions implement hook_swftools_playlist_PLAYER()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- swftools_flowplayer3_swftools_playlist_flowplayer3 in flowplayer3/
swftools_flowplayer3.module - Implementation of hook_swftools_playlist_PLAYER().
- swftools_flowplayer_swftools_playlist_flowplayer in flowplayer/
swftools_flowplayer.module - swftools_getid3_swftools_playlist_element_alter in getid3/
swftools_getid3.module - Attaches ID3 data to a SWF Tools playlist element.
- swftools_imagerotator_swftools_playlist_imagerotator in imagerotator/
swftools_imagerotator.module - Implementation of hook_swftools_playlist_PLAYER().
- swftools_jw5_swftools_playlist_jwplayer5 in jw5/
swftools_jw5.module - Implementation of hook_swftools_playlist_[player]().
File
- docs/
swftools.php, line 159 - Doxygen documentation for SWF Tools.
Code
function hook_swftools_playlist_PLAYER(&$data) {
// Get array of image rotator settings
$saved_settings = _swftools_PLAYER_settings($data['othervars']['profile']);
// Initialise a string to contain the elements
$xml = '';
// Iterate over the playlist to build elements xml
foreach ($data['othervars']['playlist_data']['playlist'] as $track => $details) {
// If imagecache is enabled see if we need to use a modified thumbnail
if ($saved_settings['imagecache'] != SWFTOOLS_UNDEFINED) {
$details['fileurl'] = swftools_imagecache_create_path($saved_settings['imagecache'], $details['fileurl']);
}
// Create an individual xml element on the raw playlist
$xml .= theme('swftools_PLAYER_playlist_element', $details);
}
// Add xml wrapper around the elements
$xml = theme('swftools_PLAYER_playlist_wrapper', $data['othervars']['playlist_data']['header'], $xml);
// Return the resulting xml
return $xml;
}