Hi there,

I've changed the onepixelout code to include the description field on the CCK, as well as offering a default titles variable on the admin form.

Flash vars can be passed from the Description CCK to the OnePixelOut player, e.g.: -

titles=Take Off|initialvolume=10 would pass "Take Off" to the titles flash var, and set the initial volume to 10.

Sorry, but I can't make patches here so I've pasted the extra lines and referenced functions instead...

In swftools_onepixelout.module: -

function _swftools_onepixelout_settings() {

  ....

  // Initialise defaults that apply if no settings were stored
  $defaults = array(
    'titles'         => '', // New line here
    'height'         => 24,
    'width'          => 290,
    'autostart'      => 'no',
    'loop'           => 'no',
    'bg'             => '',
    'leftbg'         => '',
    'rightbg'        => '',
    'rightbghover'   => '',
    'lefticon'       => '',
    'righticon'      => '',
    'righticonhover' => '',
    'text'           => '',
    'slider'         => '',
    'loader'         => '',
    'track'          => '',
    'border'         => '',
  );
  
   ....

and

function swftools_onepixelout_swftools_flashvars($action, &$methods, &$vars) {

  // Generate sequential player ids
  static $player_id = 1;
  
  // Assign the description field to the flash vars - new lines here
  $description = $vars->othervars['description'];
  if ($description) {
      $descarray = explode('|' , $description);
      foreach ($descarray as $attribute) {
        $flashvar = explode('=',$attribute);
        $vars->flashvars[$flashvar[0]] = $flashvar[1];
      }
  }
  
  ....

and

function swftools_onepixelout_swftools_variable_mapping() {
  return array(
    SWFTOOLS_ONEPIXELOUT => array(
      'titles' => 'flashvars',
      'height' => 'flashvars',
      'width' => 'flashvars',  
      'loop' => 'flashvars',
      'autostart' => 'flashvars',
      'leftbg' => 'flashvars',
      'lefticon' => 'flashvars',
      'rightbg' => 'flashvars',
      'righticon' => 'flashvars',
      'rightbghover' => 'flashvars',
      'righticonhover' => 'flashvars',
    ),
  );
}

And in swftools_onepixelout.admin.inc:

function swftools_onepixelout_admin_form() {

  .....

  $form = array();

  $form[SWFTOOLS_ONEPIXELOUT]['titles'] = array(
    '#type' => 'textfield',
    '#default_value' => $saved['titles'],
    '#title' => t('Song Titles'),
    '#description' => t('The default "titles" flashvar to be shown in the player.'),
    '#size' => 30,
  );
  
  .....

  // Unset the parameters that aren't used to populate colours
  unset($saved['titles']);
  unset($saved['height']);
  unset($saved['width']);
  unset($saved['loop']);
  unset($saved['autostart']);
  

and finally in swftools.module

function theme_swftools_formatter_swftools($element) {
  
  .....
  
  // See if we're processing a filefield and get the appropriate value
  if (isset($element['#item']['filepath'])) {
    $swf = $element['#item']['filepath'];
    $options['othervars']['description'] = $element['#item']['data']['description']; // new line here
    $source = 'filefield';
  }

I think that's it....

David

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Stuart Greenfield’s picture

I think this only applies to the newer player, not the previous version.

But I want to update / create a new module to support this player, so as part of that I'll aim to fix things here too.

Dubs’s picture

You're right actually - these vars would only apply to the new player. Hopefully this functionality can be included. Thanks again for your module!

Stuart Greenfield’s picture

Status: Patch (to be ported) » Active

Changing status to active. The necessary code to pass the title is now in place on DRUPAL-6--3, but the receiving module needs to be written to take advantage of this.

Stuart Greenfield’s picture

Status: Active » Needs review

Now working on DRUPAL-6--3.

If you use CCK (file field or link field) and assign a title / description then the WordPress audio player will use those as the title for the file.

If you use the new SWF Tools getID3 integration module and don't set an explicit title then this will grab the titles and pass them to the player, so it looks just the same as if the player did it itself.

If you don't use the getID3 feature, and don't set any titles, then the player will get the titles itself.

But if you have several files in a playlist, don't use the SWF Tools getID3 feature and assign a description to only some files in the playlist then this will prevent the ID3 from showing up on the other files. The player assumes in this case that the title you want is a blank.

Using titles in conjunction with SWF Tools own getID3 capability gives you the best of both options.

Hopefully that makes sense!

jimmb’s picture

FileSize
9.82 KB

Hello,

I'm glad to have found this topic, as I'm trying to do something very similar.... I tried adding the code above after updating all my modules to current versions. However, it resulted in a fatal error (~ unexpected syntax in "onepixelout.module" on line 203).

So I thought I should back up and explain my exact situation:

  1. I have a CCK node with an audio file upload field to upload various recordings.
  2. I've uploaded the various .mp3s to the node as per normal.
  3. Using the "Description" field, I have entered the name of each uploaded song.
  4. Then the One Pixelout Player is used to stream the songs on the node.

I'm attaching a screenshot of what the songs on the node look like right now. As you can see, it's good except the descriptions are not showing. Therefore, I need the text I've entered in the "Description" field to appear with each song (preferably above the player).

Now I'm not a coder, but the above appears to contain a bit more code than is necessary for my use case. So If someone here could help me input just the bare essentials needed to do what I'm describing, it would be much appreciated.

Thanks,

Jim

jimmb’s picture

Well, I updated SWF Tools to 6.x-3.0-beta5, and everything is working well. However, I'm still not getting a title passed to the player. Here's my setup:

  1. In my "audio" content type, the CCK audio upload field is of the "File" type
  2. For a particular audio node, I've entered some text in the "Description:" field where the .mp3 file was uploaded

But when I play that track, there is no title passed. Instead, it just says "Track #1" inside the player (see screenshot). I assume this is where the title I've specified should be seen...

Based on comment #4, it sounds like for version 6.x-3.x this should just work without needing to add the code as described above. If this is the case, then I'm not sure why it's not working. Again, any help will be appreciated.