Posted by iaminawe on July 16, 2009 at 11:04am
Jump to:
| Project: | XSPF Playlist |
| Version: | 6.x-1.0-alpha2 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi,
I have finally managed to get this module to work with CCK filefields and the FLV Media player but I have a question with regards the title that is output in the playlist.
At current I am using a multiple filefield and it correctly adds the different files to the xspf playlist but the title of each is set to the node title.
Would it be possible for the file title in the playlist field to be set to its description as enabled through the fields configuration? Then my four different videos would have four different titles based on what is entered into their description via the node edit screen
This would be awesome... can anyone assist?
Thanks
Gregg
Comments
#1
Here is a modified xspf_playlist_cck_filefield_handler from my xspf_playlist_cck.module, it uses filefield's description as title. It first try to use the 'title' set by FileField, then the description and finally the file name (without the extension). As a bonus, it also set to type and duration field and remove the identifier one (see http://drupal.org/node/524878).
<?phpfunction xspf_playlist_cck_filefield_handler($node, $field_name) {
global $base_url;
$items = array();
// extract all the embeded items from this field
foreach ($node->{$field_name} as $field) {
if ($field['filepath']) {
if ($xspf_item = xspf_playlist_node_build_file_item($node, $base_url . $field['filepath'])) {
foreach($xspf_item as $delta => &$xspf_field) {
switch($xspf_field['key']){
case 'identifier':
//unset($xspf_item[$delta]);
break;
case 'title':
if($field['data']['title']) {
$xspf_field['value'] = check_plain($field['data']['title']);
} elseif ($field['data']['description']) {
$xspf_field['value'] = check_plain($field['data']['description']);
} else {
$path_info = pathinfo($field['filepath']);
$xspf_field['value'] = $path_info['filename'];
}
break;
case 'meta':
switch($xspf_field['attributes']['rel']) {
case 'type':
if($field['filemime']) {
$xspf_field['value'] = $field['filemime'];
}
}
break;
}
}
if($field['data']['duration']) {
$xspf_item[] = array(
'key' => 'duration',
'value' => (int) ($field['data']['duration'] * 1000)
);
}
$items[] = $xspf_item;
}
}
}
return $items;
}
?>
#2
Thanks Mongolito, unfortunately didn't work for me using the description field. Not sure why exactly but I have moved on from using Filefield and trying to get a similar thing working with the CCK link field. If you can assist over at http://drupal.org/node/526608 I would be so grateful.
#3
Can you please help explain how you got filefields to work with XSPF Playlist and FLV Player? I've described my problem in http://drupal.org/node/494818#comment-2171410 . I feel like a real dufus because I've been trying for 2 weeks to create a simple mp3 playlist and I keep hitting brick walls.
Thanks very much if you can help.
#4
This thread http://drupal.org/node/374238 has a patch that should enable you to see filefields in this reference.
#5
One could probably also use
hook_xspf_playlist_list_alterorhook__xspf_playlist_item_alterto achieve similar results without patching xspf_playlist_cck.module.