ok i manage to create my playlist by scanning my media folder (glob() php) function to build the playlist but currently if the file is having chinese/japanese names will have issue while playing. for now a test my mp3 file name is this (note i am under linux hosting)

01-中国话.mp3 <-- file name

but during my view source code for the jplaylist

i saw this

title:"Öйú»°", mp3:"playfile.php?file=01-�й���.mp3", artist:"S.H.E"

as you can see i am having this 01-���.mp3 instead...

the way i am getting the file name is something like this

       foreach(glob("{$directory}/*.{$extension}") as $file) {
            $ThisFileInfo = $getID3->analyze($file);
            $songs = new Songs;
            $songs->setTitle($ThisFileInfo['tags_html']['id3v2']['title'][0]);
            $songs->setFileName($ThisFileInfo['filename']); // set file Name
            $songs->setArtist($ThisFileInfo['tags_html']['id3v2']['artist'][0]);
            $files[$file] = $songs;
        }

then output it like this

echo $comma.'{title:"'.$obj->getTitle().'",'.$plspacer.'mp3:"playfile.php?file='.$obj->getFileName().'",'.$plspacer.'artist:"'.$obj->getArtist().'"}';      
有帮助吗?

解决方案

It looks like you are trying to output a JavaScript object literal. Try using JSON-encoding for this:

echo json_encode(array(
    'title' => $obj->getTitle(),
    'mp3' => 'playfile.php?file=' . urlencode($obj->getFileName()),
    'artist' => $obj->getArtist()
));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top