Download & Extend

Option to have the player in a popup window

Project:Audio
Version:6.x-1.x-dev
Component:players
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

Hi there,

is it possible to make audio player to pop up in a little window so when you navigate from the page it won't stop?

Thanks for your help!

Comments

#1

FYI - "Popup playlist"
http://drupal.org/node/236726

#2

Thanks, but it didn't help

#3

I could really use some help on this same issue.

#4

Title:Popup audio player» 1pixout audio player open in popup window.
Version:5.x-1.3» 5.x-2.x-dev
Status:active» needs review

I finally go this to work with 1PixelOut Player. I'm sure it would be similar for the other players.

Only requires changing one function. You could add this function to your template.php file (I think that would work) or just replace the function in /audio/players/1pixelout.inc (that's what I did)

function theme_audio_1pixelout_node_player($node, $options = array()) {
  // make sure it's compatible with the flash player
  if (!audio_is_flash_playable($node)) {
    return NULL;
  }

  $node_title = $node->title_format;
  $options['soundFile'] = check_url($node->url_play);
  $url = base_path() . drupal_get_path('module', 'audio') .'/players/1pixelout.swf';
  $flashvars = audio_query_string_encode($options);



  $outplayer = '<html><head></head><body style="margin:0px;padding: 0px;">'.$node_title.'<br><object type="application/x-shockwave-flash" data="'.$url.'" width="290" height="24" ><param name="movie" value="'.$url.'" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="FlashVars" value="'.$flashvars.'" /><embed src="'.$url.'" flashvars="'.$flashvars.'" width="290" height="24" /></object><br><a href="javascript:self.close();">Close Window</a></body></html>';

$output = <<<EOT
<script type="text/javascript">
function Audiopop()
{
  AudioPop=window.open('','audioWin','width=300,height=50,left=100,top=200,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
  AudioPop.document.writeln('$outplayer');
  AudioPop.document.close();
  AudioPop.focus();
}
</script>
<a href="javascript:Audiopop();">Stream</a>
EOT;

  return $output;
}

Hope this helps someone.

#5

subscribe

#6

Hey artis thanx for that code snip..I did have to change a few things to get it to work for my drupal install...

I changed

$flashvars = audio_query_string_encode($options);

to

$flashvars = drupal_query_string_encode($options);

I pretty sure I had to do that because I have a newer version of the audio module?

also I was getting !title for the song title...

so $outplayer = '<html><head></head><body style="margin:0px;padding: 0px;">'

became

$outplayer = '<html><head><title>'.$node_title.'</title></head><body style="margin:0px;padding: 0px;">'

Another thing I changed (that has nothing to do with your code snip)...I needed the player to auto start...So I used http://drupal.org/node/34043 and used the autostart variable in my theme's template.php file..

After that everything worked great but one thing... If I have a page of songs generated by a view then the player will only pop up the last song in the list... So no matter what song I click on it will only play the very last one on the page... I dont really have a clue why just yet..I am guessing its something to do with the way views generates its view and the way the flashvars are passed? If I can figure it out I'll post an update.

#7

I have a semi simple recipe for getting a popup player working with views. I am using views2 along with views_customfield (http://drupal.org/project/views_customfield) and audio 6.x-1.0-unstable4.

1. Set up a page view with a path of mp3player and with one argument set to node:nid.
For the fields you can just use Audio:Player ...set to your favorite embedded player.

2. Now you can use that mp3player page you just set up for future views by using a views_customfield field.
For almost any view that will display just audio nodes......
A: Add a Node:Nid field and set it to hidden then move its order to the top of the fields.
B: Add a views_customfield field below and set it to Customfield: PHP code . In the code box use something like this...

<?php
 
global $base_url;
 
$audio_nid = $data->nid;
 
$output = <<<EOT
<script type="text/javascript">
var newwindow;
function audiopop(url)
{
    newwindow=window.open(url,'name','height=50,width=300,left=100,top=200');
    if (window.focus) {newwindow.focus()}
}
</script>
<a href="javascript:audiopop('$base_url/mp3player/$audio_nid');">Play</a>
EOT;
print
$output;
?>

That will put a link in a field in your view to your mp3player view page set to play the audio nid that pops up in the new window. You can then make a theme page-mp3player.tpl.php page in your theme so that only the view is shown. You could start off with a simple..

<?php
print $content
?>
in the page and go from there etc.

BTW

artis's original code works out of the box for me with audio 6.x-1.0-unstable4 for regular node viewing or views set to node view.

#8

Title:1pixout audio player open in popup window.» Option to have the player in a popup window
Version:5.x-2.x-dev» 6.x-1.x-dev
Category:support request» feature request
Status:needs review» needs work

Marked #236726: popup playlist as a duplicate.

The ideal feature would probably provide the option to display any player in a popup window.

#9

I just wrote a page in the handbook that describes, in way too much detail, how to do this:

Open the player in new window

There's a couple of things I wrote about that I didn't see here, such as including the JavaScript in a separate file for multiple players on a page, and writing the popup link using JavaScript so that people with scripting disabled won't see a broken link. It also uses the theming method from the Theming the Flash Player tutorial--that is, it defines the colors in an array, and passes them to theme_audio_1pixelout_node_player() to get the HTML.

I'm already using it on my own site, so I know it works.

nobody click here