The recent developments in the audio module are really great! It seems to be just what I need for my site, but some things leave me confused. I've read several posts with similar issues, but no definitive and/or clear solutions to this (listed below). I am assuming (perhaps incorrectly) that the idea of assigning an audio node to another piece of content and therefore creating a playlist for it would be that at some point somewhere this playlist could be viewed and played as a unit. Obviously, the XSPF player is the one to be able to do this. Here is what I have done so far, what works and what doesn't:

1. I've created 4 mp3 audio nodes and assigned them to the same playlist (attached them to the same piece of content with Attach Audio Files and Audio Feeds both enabled). Ideally if the XSPF player is chosen as the default for playback of mp3 files the player should display all four audio files in one playlist in a single player window rather than four separate player windows with one file each (http://anthonymosakowski.com/node/6) which is what I currently have. If this is not the intended functionality of the module(s), then perhaps this could be made a feature request? It would be very elegant.

2. I've also tried to create my own view using the audio playlist views type. I managed to get more than one file to show up and play in the player, but not as expected. I have a page view defined as Type: Audio XSPF/M3U/PLS Playlist. I have filters for published=YES and Node Type is one of Audio. As far as I can tell this should provide a view which includes any audio I have on my site. So far I only have those 4 files. In the player view (http://anthonymosakowski.com/player) however I get only two files, and the second one is listed as "unspecified". Both files playback fine. Perhaps I've missed a step.

If anyone has any ideas, please pass them along.

Anthony

some similar threads: http://drupal.org/node/209562 http://drupal.org/node/181118 http://drupal.org/node/207000 http://drupal.org/node/200656

Comments

kevinsmith’s picture

Looks like you've figured it out, as the player on your site is displaying two songs in one extended player. Mind helping us out on this?

Also, I'd recommend that there be a 3rd option under 'audio settings > players' for which kind of player we'd like to use for the playlist. The reasoning being that I might want to use the extended player for playlists, but not for individual nodes.

zirafa’s picture

Title: how are playlists "supposed" to work? (esp w/extended player) » XSPF playlist generated by Views not working in flash player
Category: support » bug

Changing title to reflect the combined issue, and pointing related issues to this one. It seems that the main issue is with the views generation of playlists, and the playlist is breaking, creating issues with the player.

Anthonym, for #1 you can create a one-player-for-all type functionality through the theme. See issue #139581. A patch to make this a configurable option would be great.

For #2, it sounds like the XSPF generated by the view is breaking. I'm not sure exactly why.

zirafa’s picture

Superkev07: At this time, the extended player is hardcoded as the default player for the views playlist. Changing the player in the audio settings will change the per-node player, but not the views generated player, so they aren't related. I agree it should be a configurable setting, I'll accept patches for that behavior.

kevinsmith’s picture

You're referring to the views bonus: audio playlist, right? I've got that module installed, but it doesn't show up as a view type. Is that what I'm supposed to be looking for? It doesn't appear that the JW MP3 Player required by the module is available anymore.

zirafa’s picture

No, I'm referring to audio_feeds.module that comes with 5.x-2.x-dev. The Views Bonus: audio playlist is a different module. The audio_feeds.module gives you a view type called Audio: XSPF/M3U/PLS in the dropdown.

kevinsmith’s picture

Aaaand, that explains it. Alright, I'd tried that and received this error on the page view:

user warning: Unknown column 'audio_metadata_track.value' in 'field list' query: SELECT node.nid, audio_metadata_track.value + 0 AS audio_metadata_track_value FROM node node WHERE (node.status = '1') AND (node.type IN ('audio')) ORDER BY audio_metadata_track_value ASC LIMIT 0, 10 in /home/heatwig7/public_html/includes/database.mysql.inc on line 172.

kevinsmith’s picture

Update: Apparently it's because I tried to sort by track. Just deleted that option in the view, and I was fine.

zirafa’s picture

Status: Active » Fixed

Sounds like you got the views part working. I'm going to mark this as fixed.

anthonym’s picture

Status: Fixed » Active

After much head scratching and some troubleshooting I've managed to get a XSPF playlist feed view working with the extended player showing 4 audio files all listed and playable, but there are still some questions remaining.

I found the following: Audio files uploaded individually don't seem to appear correctly in the playlist feed view for the extended player. However, the same files when uploaded via ftp and then imported as a batch via the Audio import module do display correctly. So far I have done this with 4 files only, so I don't know what will happen with any additional files either uploaded individually or in a batch. My extended player view with the four files included can be found here: http://anthonymosakowski.com/player I've copied the output of the view export tab below in case it might be useful to anyone who knows how to decipher it.

One remaining question (for now) concerns the way the player lists the tracks. They are listed with a number and my name as the artist (they are my compositions) while in the the individual audio nodes, the tracks are listed in the player with the title (e.g. http://anthonymosakowski.com/node/24). Why the difference? I would prefer if the extended player in the feed view had tracks listed by title as well so they can be distinguished from one another. Right now they all look the same.

Also I'd like to reiterate my feature request for having multiple files appear automatically in an extended player for any node with an attached playlist (without having to resort to themeing which I haven't quite had the time to learn about yet). Anyone else think this is a good idea?

I changed the status of this issue back to active. Apologies if this is a breach of etiquette.

Anthony

$view = new stdClass();
$view->name = 'player';
$view->description = '';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'audio_feeds';
$view->url = 'player';
$view->use_pager = FALSE;
$view->nodes_per_page = '10';
$view->sort = array (
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'audio_metadata_title',
'field' => 'value',
'label' => '',
'defaultsort' => 'ASC',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'audio',
),
),
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
);
$view->exposed_filter = array (
);
$view->requires = array(audio_metadata_title, node);
$views[$view->name] = $view;

madcasey10’s picture

Hey,

I've gotten a couple of messages asking how I solved this problem. My answer isn't going to be very satisfactory, but it does end up being the easiest, most reliable way to get a playlist on your site.

Basically, I just downloaded the universal XSPF player (http://musicplayer.sourceforge.net/), configured it, and embedded the code in my site (can be done as a page block, a blog post, or even straight up in the html). As long as you upload your personal playlist (and, obviously, all of your preferred mp3 files) to the same directory as the XSPF player, it will work.

Of course, you have to update/change the songs by hand, which isn't nearly as neat as doing it dynamically from your Drupal admin tools, but if you're just looking to host the same songs for quite a while (like if you're a band) this method works like a charm. Details instructions for configuring and embedding the XSPF on your site (Drupal or otherwise) are here, or just search Google:

http://musicplayer.sourceforge.net/

anthonym’s picture

The trick for me seemed to be uploading files via ftp and then importing them as a group via Audio Import (Administer >> Content Management >> Audio Import). It would be good to have some other users confirm whether or not this actually makes the XSPF playlist "work" versus creating individual audio nodes. As I said above I haven't yet had the time to upload any additional files to see if they will appear in the the playlist or not, but I do still have questions about the way the files are displayed in the playlist/player? Anyone have any guesses on this? Am I missing some way to control exactly what information is displayed for each track in the XSPF extended player?

anthonym’s picture

I was able to test this a little more. I uploaded some additional files via ftp and then imported using Audio Import as described above. Happily, the second batch of files was correctly added to my XSPF player view. I don't want to mess with success and test to see if any individually uploaded files will do the same. I hope this helps people who have been having trouble with this. It is more of a workaround than a fix, but perhaps will provide some clues to make the playlist feed work correctly no matter what method is used for uploading audio files.

I still am not satisfied with the way the files are displayed in the player however. These are all my own compositions, so I am listed as the author on the tags. And the way the playlist feed is generated it seems to put the author information first. This might work well for some sites, but not for others. I found the following lines of code in the feeds.inc file which seem (to me) to control the order of the audio tags in the generated playlist feed.

  $output .= '<trackList>';
  foreach ($items as $item) {
      $output .= '<track>';
      $output .= "<location>". check_plain($item['enclosure']['url']) ."</location>";
      $output .= "<creator>". check_plain($item['author']) ."</creator>";
      $output .= "<album>". check_plain($item['album']) ."</album>";
      $output .= "<title>". check_plain($item['title']) ."</title>";
      $annotation = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
      $output .= "<annotation>". check_plain($annotation) ."</annotation>";
      $output .= "<duration>". check_plain($item['duration']) ."</duration>";
      $output .= "<image>". check_plain($item['image']['url']) ."</image>";
      $output .= "<info>". check_plain($item['link']) ."</info>";
      $output .= '</track>';

I don't know want to mess with this and break anything, but would it be possible to make the order of the tags in the playlist info customizable, perhaps in a views tab or somewhere else? If not, maybe someone could guide me on how to safely alter the code to get what I need: just a listing of title, no author.

zirafa’s picture

Hey Anthonym,

I haven't had a chance to work on this lately, but would accept any patches to make this setting configurable. You are right that feeds.inc is responsible for the way the title displays. The reason it displays this way is because the XSPF player uses the annotation variable to set the visible title for each track. On the XSPF player website you can see that they have set the annotation to display as ARTIST - TITLE and I just assumed this to be the best practice for this player.

If you wish to manually change this, you can modify feeds.inc to display what you want. On line 73 of feeds.inc you can change annotation to simply be the title.

BEFORE:

$annotation = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];

AFTER:

$annotation = $item['title'];

It'd be better if no code hacking was needed, though. Perhaps it could be a theme function that could be overridden.

anthonym’s picture

Thanks Zirafa,

I was reluctant to hack the code, but when I have some time I will experiment with it. I agree that some sort of theme override would be good. Patching and theming is a little out of my element at the moment. I'll report back on what success I have.

Anthony

perke’s picture

anthonym, thanks for the exported view.... I've been banging of the wall too for some time now to get all audio nodes to show in one flash player and that saved my day...again, much thanks

anthonym’s picture

perke,

Glad my post helped you solve your issue.

Anthony

anthonym’s picture

Zirafa,

I changed the code in feeds.inc as suggested, but the XSPF player is still not displaying my tracks by title. The really weird thing is that I checked the xspf feed file being generated (by viewing the source of the xspf link in my browser) and the annotation tag did change to just the title after changing that line of code. Could there be something else feeding this information to the player? I cleared the views cache just in case this might have been the culprit, but that didn't seem to have any effect. Any ideas?

Anthony

anthonym’s picture

Zirafa,

I'm still fiddling with things to present my audio just the way I want it. As reported above, the change I made to feeds.inc had no effect on the display of tracks in the player. After a little digging online, I found the following on the Lacy Morrow website (http://lacymorrow.com/projects/xspfwmp/xspfdoc.html)

annotation and creator/title are interchangeable. creator/title provides more functionality

It seems that the web player is overriding the annotation tag and choosing to display a combination of creator and title instead. So, for my purposes I commented out the <creator> tag definition line in feeds.inc. This is probably far from ideal, but I don't know if anything else can be done about it.

stuffnthings’s picture

I am having the same problem as the title of this post rather than the display of the mp3 display issue now in motion.
the need is for xspf playlists to work in views. I am sorting by album and want to generate a playlist of that album, I can get the view to work with : entire node and feeds and everything except xspf playlists. The view I get is a non populated empty playlist with my site info only for Title.

Do I have it installed correctly, hardly any info from the developer on that?
Are there any specific filters or sorts to add?

Why won't views show me a playlist with files in it?

manimal’s picture

stuffnthings: I just posted an issue about this and I found that if I had clean urls disabled on the site, then no tracks would load in the views created playlists.

you could try turning those off and on to see if that has any effect on the playlists.

also sorry if I posted a duplicate.. didn't find this one, and it seemed like the issue was solved..

stuffnthings’s picture

manimal: thanx for your input but that is not the fix, however you are on the right track. I do have bad characters breaking feeds. I tried a feed.inc patch with no success from http://drupal.org/node/212913#comment-746871 and could not get that to work, so I am still on the hunt for the ever elusive bad character display holy grail fix.

Still no tracks on the track list.

sam_squarewave’s picture

When clicking on any of the fee links I'm getting this error:

Fatal error: Cannot use object of type stdClass as array in /home/sagreene/public_html/drupal_samgreene/modules/audio/contrib/feeds/audio_feeds_views.inc on line 72

I also have an empty player.

Thanks for any help.

sam_squarewave’s picture

I went into the php and changed

'duration' => $audio->audio_file['playtime'],

to

'duration' => '0',

which makes me think that the playtime field is wrong...and yes, it does not exist in the audio_file table.

Have I messed up my installation somehow?

I had the stable audio version first and then replaced the folder with the -dev version with feeds. The modules showed up, but the main audio module still shows the old version - Audio 5.x-1.4

Thanks!

AthenaAdam’s picture

anthonym plz tell us how u succeeded in showing playlist xspf extended player.. it is showing very well at ur site. Please share with us. I am struggling with it for so long.. I am using dev version of audio module in d6.

anthonym’s picture

Hi. I'd like to help. Can you give me something a little more specific to answer? Honestly I haven't spent any time updating my site recently, so exactly how I got it to work is a little foggy.

Anthony

renoproc’s picture

You can go see the good tuto of Niall here : http://fuseinteractive.ca/blog/drupal-xspf-0

Drupal + XSPF
March 1st, 2010

Having worked on many Drupal sites with music players I have used a number of solutions but never quite found something that worked perfectly for me. Recently I have done a number of sites that required the ability to have a play list that is easily managed by the client without messing around with xml files and ftp uploads. There are a couple solutions for this but i am going to focus on one solution which is using the XSPF Playlist module.

Step 1: Enable the modules.

- XSPF Player - http://prdownloads.sourceforge.net/musicplayer/xspf_player-0.2.3.zip?dow...
- XSPF Playlist Module - http://drupal.org/project/xspf_playlist
- Views 2 - http://drupal.org/project/views
- CCK - http://drupal.org/project/cck
- Upload - Comes in Drupal core.

Step 2: Create your content type.

next you'll want to create a custom content type to upload the mp3 files to(admin/content/types/add) , I named mine playlist items.
Do not add any upload file field, the default File attachments will be sufficient.
You can get rid of the body since you won't need it unless you want to use the node in another page then pop down to "Workflow Settings" and turn on file attachments. All you are going to need is a title and the Standard file attachment.
Also note that the file size is going to be constrained by what your server settings will let you upload so if you want to add large size mp3's that will need to be tweaked. Your ability to do this will depend on your hosting situation.

Step 3: Configure XSPF Playlist.

After you have created your content type you will need to enable it in XSPF to allow the module to create playlists from the nodes (admin/settings/xspf_playlist).
Here you can title the playlist that will be created as well. In content settings you select your CCK and click save. Now there's a little bit of a trick i found, if you are using the admin menu module you will need to flush your cache on it for the playlist settings to show in the menu. You can then go to this link through admin menu or /admin/settings/xspf_playlist/name-of_your_content_type. Here you will select the field that contains the mp3 and thumbnail to show in the player for this setup you will want "Drupal: Upload Attached Files". (Please note that currently there seems to be a problem in the D6 version with correctly pulling the thumbnail. You can, however, set a default cover to show for all tracks.

Step 4: Create your view.

Once you have your content type and your XSPF settings done you will need to create a view to generate the xml for the player to read. Start by creating a new node view, the main display you will need is the FEED display.
here's a list of the basic settings to get it going.
- items to display:Unlimited
- Style:XSPF Playlist
- Row Style: Node XSPF
You'll need to give it a path i just used /playlist for mine and then as always you'll need some filters so select node type and as a rule i always add node published: Yes
You can then sort the view however you choose and save your work.

Note: This view does not utilize any fields so other than the couple style settings, path, sorts and filters there is not much to set up.

Step 5: Embed the player in a block/page.

The last thing to do is set up the actual player. To do that you will need to place the downloaded swf somewhere in your drupal install's file structure. I like to place all my swf's in my themes directory to keep things clean. Once you have done that you will need to either create a page or a block, set the input format to full HTML and enter the following embed code in in the body:

Set the location for the swf to the path from the root of your install and enter the path to the feed you set up for the playlist_url and that's it. You have an audio player that requires no xml knowledge to maintain.

This will get you started with a basic set up from there you can use views sorting, filters and arguments to control your playlists however you want. Depending on your ability there are many players out there to skin and use on your site that accept XSPF playlists.

I hope all this will help.