Reputation: 1
Hello and thank you in advance! I'm a photographer and musician who also understands CSS, but java and php... not so much.
I'm using code from the legacy jPlayer to build a music site. Everything works as it should, but I can't figure how to remove the file extensions from the song titles.
Screenshot: Playlist
As far as I can tell, this is the code that generates the playlist. I'm using the filename only option, near the bottom:
<?php
asort($fileinfo);
foreach ($fileinfo as $value) {
if($relMusicDir=='./') $showfrom='[from '.$value['from'].']<br /> ';
if($useID3==TRUE){
//WORKS
//echo$comma.'{name:"'.$value['artist'].' - '.$value['title'].'",mp3:"'.$relMusicDir.$value['filename'].'"}';
//TRY
//if artist or title are empty, use filename
if( (!isset($value['artist'])) AND (!isset($value['title'])) )
echo$comma.'{name:"'.$showfrom.$value['filename'].'",flac:"'.$value['path'].'"}';
//skip, if filename or path are empty
else if( (isset($value['filename'])) OR (isset($value['path'])) ){
echo$comma.'{name:"'.$showfrom.$value['artist'].' - '.$value['title'].'",flac:"'.$value['path'].'"}';
}
}
else //assume filename only
//WORKS
//echo$comma.'{name:"'.$value.'",mp3:"'.$relMusicDir.$value.'"}';
//TRY
echo$comma.'{name:"'.$showfrom.$value['fn'].'",flac:"'.$value['path'].'"}';
$comma=','."\n\t\t";
}
?>
Upvotes: 0
Views: 43
Reputation: 1
Figured it out. At "assume filename only," I modified the last few lines of code like this:
else //assume filename only
//WORKS
//echo$comma.'{name:"'.$value.'",mp3:"'.$relMusicDir.$value.'"}';
//TRY
$withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $value['fn']);
echo$comma.'{name:"'.$withoutExt.'",flac:"'.$value['path'].'"}';
$comma=','."\n\t\t";
Upvotes: 0