You are here

function swftools_generate_playlist in SWF Tools 6.3

Same name and namespace in other branches
  1. 5 swftools.module \swftools_generate_playlist()
  2. 6 swftools.module \swftools_generate_playlist()
  3. 6.2 swftools.module \swftools_generate_playlist()

Generates an playlist and places it in {cache_swftools} ready for use.

This relies on player modules implementing hook_swftools_playlist_[player]. A module implementing this hook may either return an xml string that will be used by the player, or it may update the data array directly.

We don't check for the existence of this content in the cache already. If we are here then the swf wasn't in the cache, so the xml isn't either.

We used to create an actual file. Now we place the content in {cache_swftools} and access it via swftools/playlist/nnn, where nnn is the cid.

The xml result from this function is attached to $options['othervars']['xml'] and the the calling swf() function will cache this for us.

Parameters

&$options: The SWF Tools data array for this element.

Return value

The path to the virtual xml file (will be in the form swftools/playlist/nnn), or an empty string (SWFTOOLS_NON_XML_PLAYLIST) if there is no xml.

1 call to swftools_generate_playlist()
swf in ./swftools.module
Processes a file, or an array of files, and returns the relevant mark-up to render a Flash based player.

File

./swftools.module, line 735
The primary component of SWF Tools that enables comprehensive media handling.

Code

function swftools_generate_playlist(&$options) {

  // Determine the name of the hook that would be used to generate an xml playlist
  $hook = '_swftools_playlist_' . $options['resolved_methods']['player']['name'];

  // Build the name of the function we would call
  $function = $options['resolved_methods']['player']['module'] . $hook;

  // See if the function exists - if it doesn't the module doesn't implement this hook
  if (function_exists($function)) {

    // Call the function and pass variables by reference
    $playlist = $function($options);

    // If playlist is not empty this is an xml playlist
    if ($playlist) {

      // Store the result on to $optinos['othervars']['xml']
      $options['othervars']['xml'] = $playlist;

      // Return the path to the xml
      //      return url('swftools/playlist/' . $options['othervars']['cid'] . '.xml');
      return url('swftools/playlist/' . $options['othervars']['cid']);
    }
  }

  // We don't have hook_swftools_playlist_[player] for this player, return an empty string
  return SWFTOOLS_NON_XML_PLAYLIST;
}