There is a width setting for the JW media player but not for the 1pixelout player. The new pixel mp3 player supports width, how can I update the module so that I can specify width for the 1pixel out player?

thanks!

Comments

been looking for an answer to this as well. any luck?

I really want this to and could probably supply a patch to add this in - I just don't know where in the world to set the width of the 1pixelout player. I can't find it in the 1pixelout documentation at all. Can you point me to it? When I just change the width attribute, it changes the height, too.

I've made a hack for this problem. On my site users can upload a number of mp3s. In my template.php file I've created the following function. This is called in the node_preprocess function.

<?php
function yourtheme_1pixelresize($mp3array, $newwidth) {
$pos = 0;
foreach(
$mp3array as $mp3)
    {   
$newmp3text = str_replace('"width": 290', '"width":' . $newwidth , $mp3[view]);
       
$newmp3text = str_replace('"290"', '"' . $newwidth . '"', $mp3[view]);
       
$mp3array[$pos][view] = $newmp3text;
       
$pos ++;
    }
return
$mp3array;
}
?>

This is called when I want to include a player in my *.tpl.php files like so:

                        <h6>Samples MP3s</h6>
                        <?php  foreach($node->uploadedmp3s as $mp3)
                        {  print
$mp3[view]; }
                       
?>

This won't be applicable to everyone but hopefully it's of some help to someone. If anyone knows a better way to do this please educate me!

B

Changing the size of the 1pixelout player object just makes it look ugly -- I tried this on a site.

The proper solution would be for the player to take a width parameter and draw itself accordingly.

Any one find a solution here yet? It's almost useless if you can't set the width to fit in your block or where ever you need to place this.

Good news everyone! http://drupal.org/project/mp3player This module integrates the latest player version and has a width parameter setting. YAY!

Erm... great, but can we get it supported in SWF tools rather than go back to the D5 situation of having different modules for different media players?

i tried to modify the source to do this, but no matter what i changed it wanted to show up at 290px. i thought changing the width in the $media_player array in onepixelout_swftools_methods() would do something, but it had no affect. so, does anyone know how to resize this thing? as superduperdan said, its kind of useless to have a player be a fixed width if you want it to have any flexibility for your site design.

Solution!

This involves modifying the swftools.module file to deal with what I perceive to be an oversight.

The first thing to note is that if you set a width and height value in the $media_player array in the onepixelout.module file, this is essentially ignored. The reason (I imagine) is because you certainly don't want it overriding a param you set manually when calling the swf function in a tpl file or the like.

Most of you have tried to make that change and found it to be ineffectual. The reason is very simple and it lies in the swftools_set_size() function in the swftools.module. This function is called to ensure that both the params and the flashvars width and height are set. First it looks to see if the flashvars are set for width and height. If they are it assigns the same to params. Then the reverse, if flashvars aren't set, then it applies params to flashvars.

However, if neither are set the function then looks at the params set in the src_path for the player. Note: this isn't the mp3, its the .swf player, which (of course) returns 290x24. The function happily takes this return, assigns it to the params width and height (probably should assign it to flashvars too) and then returns.

Below that the system looks to the values set in the player module file (in that $media_player array that seems to be ignored). Well... since the 1pixelout player has it's width and height set in the .swf file, this settings will never, ever be used.

Solution. Move the two bottom if statements above the 3rd if statement. I also adjusted them to set the flashvars height and width as well since they seemed to not set them.

Here's my modification to the swftools_set_size() function:

function swftools_set_size(&$vars, $player = array()) {
  // Not a pretty piece of code, but should be ok for the moment. We are
  // purposefully passing the width and height
  // if we have them. Unsure if this will cause problems with some players.
  // It's an ugly piece of code, but will remain in this form until a clearer
  // solution arises.
  //
  // It may be that, in hook_swftools_methods, the flash player indicates that
  // it *want* certain values copied b/t params and flashvars.
  // The code below was patch to fix notice errors, but it broke flash node autodetect
  // Flash node has been patched to fix this by changing zero height / width to null
  // TODO : Is it really necessary to set the height and width in to the flashvars?
  // If flashvars are empty, but params are set, populate flashvars with params
  if (empty($vars->flashvars['width']) && empty($vars->flashvars['height'])) {
    if (!empty($vars->params['width']) && !empty($vars->params['height'])) {
      $vars->flashvars['width'] = $vars->params['width'];
      $vars->flashvars['height'] = $vars->params['height'];
      return;
    }
  }
  // If params are empty, but flashvars are set, populate params with flashvars
  if (empty($vars->params['width']) && empty($vars->params['height'])) {
    if (!empty($vars->flashvars['width']) && !empty($vars->flashvars['height'])) {
      $vars->params['width'] = $vars->flashvars['width'];
      $vars->params['height'] = $vars->flashvars['height'];
      return;
    }
  }
  // If we STILL don't have a width after all this, try to use fallback player defaults
  if (empty($vars->params['width']) && isset($player['width'])) {
    $vars->params['width'] = $player['width'];
    $vars->flashvars['width'] = $player['width'];
  }
  // If we STILL don't have a height after all this, try to use fallback player defaults
  if (empty($vars->params['height']) && isset($player['height'])) {
    $vars->params['height'] = $player['height'];
    $vars->flashvars['height'] = $player['height'];
  }
  // If still empty we try and get them from the file to be embedded
  if (empty($vars->params['height']) || empty($vars->params['width'])) {
    $info = swftools_get_info($vars->params['src_path']);
    if ($info) {
      $vars->params['height'] = $info['height'];
      $vars->params['width'] = $info['width'];
      $vars->flashvars['height'] = $info['height'];
      $vars->flashvars['width'] = $info['width'];
      return;
    };
  }
}

Voila! now your settings in the onepixelout.module file will actually stick. In theory it wouldn't be that hard to modify that file to make those two settings also be available text fields in the admin section for the player as well.

I have a problem with this also. Need to set the width on 1pixelout, can we make this an admin setting?

Height and width have been added to the admin page so that it can be over-ridden.

If a different height / width are supplied then these will be used instead when the player is rendered.

This will be committed on branch DRUPAL-6--3 shortly.

Status:Active» Needs review

Now in place on DRUPAL-6--3, so should be working and height/width can be set properly.

Has anything changed from February that I can't see these new width settings?

I'd like to know this as well. Has this been rolled into a dev release?

Well, I tried 6.x-3.0-beta4 and the site crash. Then I have to remove it and fallback with 6.x-2.5

Any update for this issue would be very much appreciated.

Thanks
Truyen

Alternatively, you can set the width for the div in the CSS file. That worked for me.

.onepixelout {width: 150px; }

The css method doesn't work for me with swftools 6.x-2.5. Haven't tried the 3.x beta yet.

Status:Needs review» Active

I don't see a patch (needs review implies there's a patch)