Ejemplo n.º 1
0
class m3uPlaylistDelegate
{
    public function getPlaylist($songs)
    {
        $m3u = "#EXTM3U\n\n";
        foreach ($songs as $song) {
            $m3u .= "#EXTINF:-1,{$song['title']}\n";
            $m3u .= "{$song['location']}\n";
        }
        return $m3u;
    }
}
class plsPlaylistDelegate
{
    public function getPlaylist($songs)
    {
        $pls = "[playlist]\nNumberOfEntries=" . count($songs) . "\n\n";
        foreach ($songs as $songCount => $song) {
            $counter = $songCount + 1;
            $pls .= "File{$counter}={$song['location']}\n";
            $pls .= "Title{$counter}={$song['title']}\n";
            $pls .= "Length{$counter}=-1\n\n";
        }
        return $pls;
    }
}
$externalRetrievedType = 'pls';
$playlist = new newPlaylist($externalRetrievedType);
$playlist->addSong('/home/aaron/music/brr.mp3', 'Brr');
$playlist->addSong('/home/aaron/music/goodbye.mp3', 'Goodbye');
echo $playlist->getPlaylist();
Ejemplo n.º 2
0
{
    public function getPlaylist($songs)
    {
        $m3u = "#EXTM3U\n\n";
        foreach ($songs as $song) {
            $m3u .= "#EXTINF: -1, {$song['title']}\n";
            $m3u .= "{$song['location']}\n";
        }
        return $m3u;
    }
}
class plsPlaylist
{
    public function getPlaylist($songs)
    {
        $pls = "[playlist]]\nNumberOfEntries = " . count($songs) . "\n\n";
        foreach ($songs as $songCount => $song) {
            $counter = $songCount + 1;
            $pls .= "File{$counter} = {$song['location']}\n";
            $pls .= "Title{$counter} = {$song['title']}\n";
            $pls .= "LengthP{$counter} = -1 \n\n";
        }
        return $pls;
    }
}
$externalRetrievedType = "pls";
$playlist = new newPlaylist($externalRetrievedType);
$playlist->addSong("/home/aaron/music/brr.mp3", "Brr");
$playlist->addSong("/home/aaron/music/goodbye.mp3", "Goodbye");
$playlistContent = $playlist->getPlaylist();
echo $playlistContent;