Your module is essential! Thank you for all the great work...

i'm a bit of a newbie, though, and can't find any instructions on how to implement XSP Playlist. Your readme file advises:

"You can generate a xspf playlist for a node by using the url:
http//mysite.com/xspf/node/NID
where NID is the node id of the node that you want the playlist for."

...but i don't know where to insert my node id address in your module. Any directions, no matter how brief, would be greatly appreciated. Thanks...

Comments

arthurf’s picture

Huh, I guess my intuitive directions are not so intuitive :)

The idea is the following: you have http://mysite.com/node/33. You've attached a few mp3 and flv files to node/33 via the upload module. If you've got your xspf_playlist settings right, if you goto http://mysite.com/xspf/node/33 you will generate a xspf play list from the attachments on that node.

What you need to do now is feed the url (http://mysite.com/xspf/node/33) to your flash player. You can do this in node.tpl.php. I generally use the swfobject_api module to generate the code for my flash player. So for example, I might have this code in my node.tpl.php

<div id="video_flash_container">
  <?php 
  $params = array(
    'type' => 'playlist',
    'width' => 320, 
    'height' => 260,
    'allowfullscreen' => 'true',
  );
  
  $vars = array(
    'file' => xspf_playlist_url('xspf/node/'. $node->nid),
    'shuffle' => 'false',
    'repeat' => 'list',
    'transition' => 'fade',
  );
  print theme("swfobject_api", base_path() . path_to_theme() . '/flash/mediaplayer.swf', $params, $vars); ?>
</div>

This code assumes you have your media player stored in a directory called "flash" in your current theme directory.

ctmann’s picture

Thanks for the help. it works! Here's what i did:

-checked XSPF Playlist Permissions
-Admin/Settings/XSPF Playlist Settings/Playlist enabled
--Audio, Page, Story (other types of content freak out my system)
--Checkmarked everything else on the page (Use attached files for playlist)

-created new node, uploaded files to the node (as instructed)
--(file by file takes a LONG time. Any way to bulk upload with your module?)
- figure out the new node's number, then go to it's address at "http://www.mysite/xspf/node/NodeNumberGoesHere" This creates a new XML playlist.

< The xml file is created at files/playlists. My playlists have bizarre numerical names, so they're hard to tell apart.>

I use jeroen wijering's player for this next part, and I go to this page for the code:
http://www.jeroenwijering.com/extras/wizard.html

fill in the file to play:

fill in the location of the player:

click "Reload the player" and copy the code which appears into the new node's block body. The "full html" radio button must be selected.

*For some reason, the wijering wizard likes to add "public_html" to addresses I enter, so it's worth double checking the names of the files once I've pasted the code.

Seems to work well for me. I appreciate the prompt help and the great module!

arthurf’s picture

Status: Active » Fixed

Hi-

File uploads are controlled by Drupal core, so no, unfortunately, you have to upload your files which is dependent on your upstream speed. For many people this can be quite slow.

Good luck with your media!

butler’s picture

Hi. Installing XSPF Playlist under Drupal 5.2, I find there is a required module:

Depends on: Content (missing)

... of which I can't find any mention anywhere. I can't enable the XSPF Playlist module so it must really be required but I am wondering whether it is part of something else (CCK?), maybe a typo of the module Contento (apparently obviated in Drupal 5?), or... what? Please advise. Thanks very much for all your efforts.

Best,
CDB

aperj’s picture

Hello,

I was able to get everything to work by following the instructions (enabling the modules, attaching mp3 files, etc).

The only thing it's not doing is creating the xml file at /files/playlists. When I browse to the url "/xspf/node/nid" I get the xml data with all tracks but the file is never created.

Any ideas why this is? Could it be a permissions issue?

arthurf’s picture

Hi- The idea behind the xspf playlist is that it is dynamic- as people add or change content on a given node, it changes the content that is available via the playlist. It could be possible to actually write the file to reduce the overhead, but I haven't gotten there yet. Something could be done that is quite similar to imagecache....

aperj’s picture

Hello!

Thanks for your quick response. I have found a workaround by placing the following code in my template file for the node. I'm using the contemplate module and added this code to write the file before displaying the node:

<?php
     $url = xspf_playlist_url('xspf/node/'. $node->nid); 
     $data = implode("", file($url));

     $handle = fopen(file_directory_path() . '/playlists/' . $node->nid . '.xml', "w+");
     fwrite($handle,$data);
     fclose($handle); 
?>

I then use this to display the player:

     <p><embed src="http://www.mywebserver.com/files/mediaplayer.swf" width="320" height="140" allowfullscreen="true" allowscriptaccess="always" flashvars="&amp;file=http://www.mywebserver.com/<?php print( file_directory_path() . '/playlists/' . $node->nid);?>.xml&amp;height=140&amp;width=320&amp;displaywidth=120" /></p>

This will allow me to upload my files to the node and have them automatically appear in the player when viewing the node. I'm not sure how much of a hack this is but so far it's working for me.

Thanks for all of your help!!

arthurf’s picture

I'm not sure that this is really necessary. Where you do this:

file=http://www.mywebserver.com/<?php print( file_directory_path() . '/playlists/' . $node->nid);?>.xml&amp;height=140&amp;width=320&amp;displaywidth=120"

Would be the same as:

file=http://www.mywebserver.com/xspf/node/<?php print $node->nid; ?>&amp;height=140&amp;width=320&amp;displaywidth=120"

Unless you're trying to save hits on apache, I'm note sure why you'd write the file. I think there is an argument for caching and even writing the xml files for performance, but I haven't quite figured out how to keep these files fresh yet if dynamic data is a concern (which I think it is).

Anyway, I'm glad your hack works- and I'd love to understand why you need it- I'd like to make this module as useful as possible.

aperj’s picture

You are right about my not needing to write the file. I initially tried providing the xspf URL inside the "file=" argument but it wasn't working (not sure why). Now it works as you've described.

I'm building a dynamic audio player with playlists, I expect this is fairly normal usage of this module. Each song in the playlist needs to have it's own image. I'm just getting started and perhaps I'm not doing this properly, but what I've done is create a CCK type called 'playlist' and configured the xspf module to treat attached audio files as playlist items. I then use the above code to display the player along with the playlist items.

At this point when I display the player and list, each song uses the same image as well as the same title. Inside the function "xspf_playlist_create_file_item($node, $file)" within the xspf module I made this change:

From:
$item['title'] = $node->title;
to :
$item['title'] = $file->filename;

BTW, I'm not going to leave this change there -- will find a different place for it that doesn't interfere with your module.

This uses the file's title to display for the play list rather then the title of my CCK node. I'm really unsure at this point how to get a thumbnail for each song. The xml field I'm trying to populate is "". If I add an image field to my CCK type and configure the xspf module to use this field, it uses the same image for all of my songs. It seems like I need a way to upload an image along with my audio file. I'm thinking about using the audio module but I'd like to use something simpler at this point.

Do you have any ideas for what I can do to get the thumbnail per song?

aperj’s picture

The only things I can think of are:

a.) Use the Audio module to upload the songs. This module provides for using an image per audio module. I will then need to figure out how to attach the audio .mp3 file to the playlist node (perhaps I can do this programatically). I can then get the song thumbnail for the audio file. This seems like alot of work.
b.) Perhaps the GetID3() library can help if a thumbnail image is stored as part of the mp3 file?
c.) Modify my cck creation form to allow the user to upload an image along with the mp3 file. This also sounds like a lot of work since it will involve mucking around with the upload module
d.) I will also look at the version 4 playlist module to see if it can help me figure out the best approach

arthurf’s picture

If you wanted to generate your own playlist structure, it's pretty straight forward- you can use a hook which alerts xspf_playlist that you have your own way of generating your playlist:


/**
 * implemenation of hook_xspf_playlist_use
 */
function mymodule_xspf_playlist_use($op, $node, $config) {
  switch($op) {
    case 'define' :  
        // identifies your playlist type to xspf_playlist
        $define['mymodule--1'] = t('My module playlist configuration'); 
      return $define;  
    break;
    
    case 'return':
         // find files associated with this $node
        foreach($files as $file) { 
          // build a playlist item
         $item['title'] = $file->title;
         $item['author'] = $file->author;
         $item['thumbnail'] = $thumb ? $thumb : theme('xspf_playlist_thumb_get', $node);
         $item['link'] = xspf_playlist_url('node/'. $node->nid);
         $item['file'] = $file->link;
         $item['info'] = theme('xspf_playlist_info', $node, $item);
         $item['identifier'] = $file->id;
         // only return last three chars of file type
         if ($meta) { $item['type'] = $meta; }
         else { 
           $path_parts = pathinfo($url);
           $item['type'] = $path_parts['extension'];
         }
        $items[] = $item;       
        } 
     return $items;
   break;
  }
}

There is another example in the xspf_playlist module- look at xspf_playlist_xspf_playlist_use() to see how it implements this hook.

I think I could build an mp3 style playlist into the module as an option- if you can give me some pointers on how it should be done (heck, we could even try to look up album images on amazon) I'm all ears. I also gladly accept patches.

Anonymous’s picture

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

nice moduel! thanx for sharing.

would it be easy to implement the possibility to use also files attached to a node by the mediafield.module?

xcusso@drupal.cat’s picture

Xspf module works under views?
For example http://www.myhomepage.com/xspf/viewname

Thanks.

Songstress’s picture

Did anyone ever answer this for butler? I've run into the same issue -- someone point me to the "Content" module so I can install it! :)

arthurf’s picture

arthurf’s picture

Yes, this does do some integration with views. You'll need to make sure the content types are right for what is being passed via the view, but it does work

kulfi’s picture

Status: Closed (fixed) » Active

another request for documentation

arthurf’s picture

ulfk-

I'd love help getting documentation together. I've done a lot of work trying to get these modules out into the world, now I need some help from people using (or trying to use) them to write good documentation.

What do you need documentation for? What it seems unclear to you? I just added some information to the readme:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/xspf_playli...

gusaus’s picture

Agreed this module (or interaction between modules) could benefit from some more documentation, examples, case studies, etc. We're building a band site and would love to provide a real world example for 'how to' use these modules -- ideally we can give back the entire site in the form of a band site profile.

Would XSPF Playlist module and a combo of 'x, y, z' produce something like these?
* http://petergabriel.com/discography/release/Hit/259/ - click on the listen link and the track player comes up - can we do that w/ xspf and audio module? emfield? media field? all of the above?
* http://jacksonbrowne.com/discography/albums/5251.aspx - similar deal when you click on a track...

Would be great to provide a real world case study of the various tools that Drupal offers to provide this type of functionality.

aterchin’s picture

for starters, all i'd like to do is add something to the code that looks at a cck node finds an image in a specific field, and adds a <image=http://....> in the playlist to the flv file i've uploaded (for this specific cck content type/playlist entry)

What i think is causing a bit of confusion with some people is where to put the hooks and functions examples in the readme. And 'this notifies XSPF that your module...' etc.
Is this to insert in template.php? Or do you literally mean create a new module with a folder, info file, etc.. this seems to relate to what's in the flvmediaplayer settings--you've got the Media File drop-down that says 'select a module to load the media for this player...' Does this mean we could make some more like the examples in the xspf readme (automatically added to the drop down list)? if so, very cool. but again, i'm not sure where to add the code. or i could be way off here.

(Using 5.x-0.12)