I've been anxiously awaiting this code for a long time.. downloaded latest from cvs as of april 18th.

I've read the contrib module readmes to try and get playlists working but i'm confused. either i'm not doing the right thing or i've misinterpretted what this module is supposed to do.

STEPS:

1) d5 with latest greatest audio from cvs
2) i create a content type called 'playlist' and enable all the following on it:

Attachments:
Attach audio files:
Audio Feeds:

3) create a node instance of 'playlist' called 'playlist 1' and i CAN attach audio to it.

FIRST QUESTION ... each audio file is attached to the target node with its own SEPARATE PLAYER.. I would like all attached files to play as one album / playlist in ONE PLAYER (like when the extended player can have a playlist)... can i do that - see below?

4) I then go and create an audio node. There is a link called 'add to playlist' at the bottom of it. When i click on it, it takes me to

http://example.com/audio_playlist/61?destination=node/61

And i can add the song as an attachment to a number of target 'playlist' nodes.. just as it's supposed to..

NOTE: if i simply navigate here:

http://example.com/audio_playlist/

I can attach an audio file from a dropdown to multiple attach audio enabled nodes.. just like it's supposed to as well:

BUG/My ERROR/FEATURE REQUEST: Whenever you hit submit on this page (either the vanilla audio_playlist page or if sent there from a node), it redirects to the home page rather than return to the same page so you can keep adding more songs to a playlist node. That's inconvenient because a playlist usually consists of multiple songs. Anyway i'm either doing something wrong or it would be a mighty nice feature request :-)

PUZZLED

OK so "add to playlist" apparently is doing what it's supposed to which is to create a series of sequential audio attachments themed as separate individual players on a target node. That's cool.

But what i actually want as described above is to theme all of those SEPARATE audio attachments as ONE SET of flash parms (i guess your XSPF feed provides that) to ONE EXTENDED PLAYER (like the extended xspf player that presents the playlist).

How do i do that or where do I access that? For me that is really the entire goal of creating a playlist in the first place. I really don't want a user to be able to navigate to a playlist page and see a bunch of separate players for each audio file/attachment.

Ideally, I would prefer to use a snippet to insert the Single flash player with playlist feed in a block or location in a tpl.php file so that users only see a flash player with the audio files. And it would be even better if i could make it be a popup player. I'll tackle that on my own if i can at least get the basic SINGLE flash player plus playlist to work. I imagine this uses the xspf feed in some way:

http://example.com/node/63/xspf

but that by itself doesn't do anything.

So does this module provide another menu path that takes the xspf feed argument to create that player or do i need to retheme based upon the current menu paths provided? If so which menu path and which theme is triggered by it?

Hope i'm making sense because i'm sure this functionality is already provided in your module, i just don't know where to access it.

super thanks for any help you can provide.

Comments

zirafa’s picture

Priority: Critical » Normal

Hi, you'll need to do a theme override to modify the audio_attach output to have a single player that loads an XSPF playlist.

Copy the theme function into your theme's template.php (example is for garland).

/**
 *  Theme used if multiple files are attached
 */
function garland_audio_attach_list($nids, $teaser = FALSE) {
  drupal_add_css(drupal_get_path('module', 'audio_attach') .'/audio_attach.css');
  foreach ($nids as $aid) {
    $audio = node_load($aid);
    $audio = node_prepare($audio, $teaser);
    $title = $audio->status ? l($audio->title, 'node/' . $audio->nid, NULL, NULL, NULL, TRUE) : check_plain($audio->title);
    $items[] = '<div class="title">'. $title .'</div>'. theme('audio_teaser', $audio);
  }
  return theme('item_list', $items, null, 'ol', array('class' => 'audio-attach-list'));
}

To remove the audio player, just remove theme('audio_teaser', $audio).

To add an audio player with an xspf feed, take a look at how the audio_feeds does it.

    $player = audio_get_players('name', variable_get('audio_feeds_default_player', 'xspf_extended'));
    $playlist_url = url($view->real_url, NULL, NULL, TRUE);
    $output = theme($player['theme_xspf'], $playlist_url);

So, you could end up with a template.php override that looks like this:

/**
 *   EXAMPLE THEME FUNCTION OVERRIDE TO DISPLAY ONE XSPF PLAYER
 *   Theme used if multiple files are attached
 */
function garland_audio_attach_list($nids, $teaser = FALSE) {
  drupal_add_css(drupal_get_path('module', 'audio_attach') .'/audio_attach.css');
  // generate an XSPF player for this playlist
  $player = audio_get_players('name', variable_get('audio_feeds_default_player', 'xspf_extended'));
  $playlist_url = url('node/' . arg(1) .'/feed', NULL, NULL, TRUE);
  $output = theme($player['theme_xspf'], $playlist_url);
  
  foreach ($nids as $aid) {
    $audio = node_load($aid);
    $audio = node_prepare($audio, $teaser);
    $title = $audio->status ? l($audio->title, 'node/' . $audio->nid, NULL, NULL, NULL, TRUE) : check_plain($audio->title);
    $items[] = '<div class="title">'. $title .'</div>';
  }
  // removed individual players
  $output .= theme('item_list', $items, null, 'ol', array('class' => 'audio-attach-list'));
  return $output;
}
zirafa’s picture

Assigned: Unassigned » zirafa
Priority: Normal » Minor

Also, please file a separate bug report about the destination not rerouting after going to the "add to playlist" page.

zirafa’s picture

Actually don't file a bug report, it should be fixed now.

newdru’s picture

zirafa,

Couple of things..

1) your checkin fixed the redirect problem.. great!

2) your theming code worked sort of like a charm. wondering if you can help out in a few related areas.

a) your code works fine with the xspf extended player but if i try to extend your players directory by adding the jerowing 3.7 player and creating a .inc file for it, i can't get it to do everything i want but actually play the playlist????

Let me explain a bit further. I modelled jeroen player off of the .inc of the xspf player. I can get jeroen's player to display, accept and use flashvars, display my xspf feed as a playlist with links in the player that return back to the nodes.. BUT THE ONE THING IT CAN'T DO is actually just play the files. Eventhough they are listed fine and the playlist links take you back to the actual node? It's highly puzzling because it appears to have everything it needs... after all it does read the playlist at node/60/xspf and display the audio files in the flash player.

If i load the sample page that ships with the 3.7 player download.. that does work!?.. (it pulls in a direct xml file - not sure if that has anything to do with it?)

AND ODDLY ENOUGH if i switch to jeroen player 2.3, my code (.inc) works fine????

I wouldn't think i need to code the theme_XXXXX_node_player function in the .inc for that to work do i? i believe that's only for node page displays.

NOTE: i'm working on my localhost on firefox 1.5. And according to jeroen doc, 3.7 player should be compatible with Flash Player 7.

Any thoughts totally welcome?

b) If i do NOT want to display the audio feed links (XSPF, M3U, PLS) on a node display that has audio enabled on it, how can i get rid of them (probably a theme function in audio somewhere)?

c) Now that i can retheme a playlist to play in a single player, I'd like to be able to make it popup in a separate window. I can easily create a link with a target of _blank to house the extended player. the question i have is that the link needs to specify an href to populate the popup... (e.g. I can't just plug in an audio module / theme function in there. Or at least i don't think i can.. if i could my problem would be solved :-)).

So how would i achieve the popup. Is there some way to sneak it in there with javascript or do I need a custom drupal MENU PATH to wrap the player functions. Any help or a code skeleton would be might appreciated... I really want to be able to do this one..

Super thanks for your speedy replies

zirafa’s picture

a) Regarding jeroenwijering's player:
See comment #24 over here: http://drupal.org/node/102912
b) You can modify the links using hook_link_alter
http://api.drupal.org/api/5/function/hook_link_alter
c) You need to write a special menu callback to only output the HTML for the player.
Then use a javascript popup link to display it. (can also add this using link_alter).

zirafa’s picture

Status: Active » Fixed

Please try and post each issue as a separate issue with an appropriate title. Marking as fixed.

newdru’s picture

Status: Fixed » Active

hey zirafa,

i'll take your advice to separate out mutliple issues for future posts..

just wanted to wrap up one last detail here regarding hook_link_alter. I "could" use that hook, but it seems pretty inefficient. Or at least, it would probably be more efficient if i just overwrode the audio theme function that spits out the audio feed links.

which theme function and where does it live?

thanks

zirafa’s picture

Please take a look at the audio_feeds_link() hook function in audio_feeds.module. Those links are added there, not in a theme function. Using hook_link_alter is the easy way to modify and/or remove the links. If you want to modify the links on the theme layer, you'll have to modify it directly in the node.tpl.php and/or template.php files in your theme to suppress those links from appearing, but you will be modifying all the node links, not just audio_feeds.

Feel free to open a new feature request to make these feed links configurable.

zirafa’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)
jowan’s picture

I am at this stage too.
I would really like the 'launch popup player' from my playlist page like in the 4.7 version of the Audio pack.
How would i go about achieving the above?
I have looked at the audio_feeds_link() and i see there is already mention of popup in the array.

$feed_links = variable_get('audio_feeds_feed_links', array('m3u', 'pls', 'xspf', 'popup'));

I presume I can create a new value in the array called popup which can and output javascript to launch a popup and pass it the playlist.
Should i perhaps look at the audio_playlist_module in the 4.7 version for how to do this.

This is nearly perfect or what i want and feel so close just need to launch the popup but am not sure on how to format the code.

yngens’s picture

i have put the following code into my template.php and got an empty player with the list of added to the playlist audiofiles below it. what i might be doing wrong?

<?php
function theme_name_audio_attach_list($nids, $teaser = FALSE) {
  drupal_add_css(drupal_get_path('module', 'audio_attach') .'/audio_attach.css');
  // generate an XSPF player for this playlist
  $player = audio_get_players('name', variable_get('audio_feeds_default_player', 'xspf_extended'));
  $playlist_url = url('node/' . arg(1) .'/feed', NULL, NULL, TRUE);
  $output = theme($player['theme_xspf'], $playlist_url);
 
  foreach ($nids as $aid) {
    $audio = node_load($aid);
    $audio = node_prepare($audio, $teaser);
    $title = $audio->status ? l($audio->title, 'node/' . $audio->nid, NULL, NULL, NULL, TRUE) : check_plain($audio->title);
    $items[] = '<div class="title">'. $title .'</div>';
  }
  // removed individual players
  $output .= theme('item_list', $items, null, 'ol', array('class' => 'audio-attach-list'));
  return $output;
}
?>
zirafa’s picture

Have you turned on audio_feeds.module as well? You'll need that enabled to generate an xspf playlist for the player.

zirafa’s picture

I should also mention that you'll need to change the line

$playlist_url = url('node/' . arg(1) .'/feed', NULL, NULL, TRUE);

to

$playlist_url = url('node/' . arg(1) .'/xspf', NULL, NULL, TRUE);
yngens’s picture

now it is working! thank you zirafa! now the only uncomfortable thing is that i have two lists - inside and outside under the player. can you advice how to get rid of outer list, please?

zirafa’s picture

Take a look at the code, the line before return $output. That is responsible for outputting the HTML version of the playlist.

yngens’s picture

got it working and perfectly set up. thank you once again very much. will be testing further anything you come up with.

newdru’s picture

hey zirafa.

i originally posted this thread awhile ago, got it working and am revisiting the playlist again and now have a few more questions:

1) i presume all the playlist functionality is now in the 5x.1.2 tarball versions and greater right? (before we had to download from cvs to pick up those changes)

2) the update_status module is telling me i need to update to the latest greatest audio module for security reasons. I'm assuming if my site was originallly working based on the original playlist cvs versisons, that the upgrade to the 5 versions (plus update.php) should be handled smoothely right?

3) The main question: I went through this theming process to get a single player to play multiple attached files. and that worked.

but i would like to use views now to create both a page and a block view of all my playlist nodes. I want views to again create a single player for multiple attached files.

a) Which VIEW *TYPE* should i use in the view definition to make this happen?
b) which fields do i need to select in the view to make this happen?

The options that exist in my cvs version of your code don't make much sense (to me) and trying a variety of combinations is not working. One view type (forgot which one) actually displayed a single player but all the files were underneath it in separate players?

Does the single player multiple file view type exist yet? which one do i use? and which fields - playlist, audio, etc?

thanks

newdru’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

sorry.. i changed this to active again.. hope that's ok.

zirafa’s picture

Status: Postponed (maintainer needs more info) » Fixed

Hey, this is more of a resolved issue, please start a new one so that this doesn't get too long. It gets confusing to start new threads on old issues (even if the topic is the same).

If there is a security vulnerability, you should probably just upgrade and if something doesn't work file a bug report.
As for the views stuff, please check out/install the audio_feeds.module which has a views type called audio xspf/m3u/pls feed that will display a single player with the audio nodes loaded in.

drewish’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

newdru, you need the 5.x-2.x-dev release

Anonymous’s picture

Status: Fixed » Closed (fixed)
yngens’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Active

Will this be fixed for Drupal 6 too?