diff options
author | Paul Arthur <flowerysong00@yahoo.com> | 2013-01-15 00:56:42 -0500 |
---|---|---|
committer | Paul Arthur <flowerysong00@yahoo.com> | 2013-01-15 11:30:47 -0500 |
commit | e2ca05d5b419944adb3723ab0253c7c35418a0e4 (patch) | |
tree | f4d0635b3690cd6c060acf69c3afebc8a7e67284 /stream.php | |
parent | e2484ee9a0e7f7de16fe2b3d015af59f0c9111c0 (diff) | |
download | ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.tar.gz ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.tar.bz2 ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.zip |
Make playlist downloads idempotent
Should fix the VLC plugin, as well as allow direct use of an Ampache
site on Android devices.
First, split the Stream class into an instantiable class that does the
playlist wrangling and a static class that handles the streaming stuff.
How does this work? Well, stream.php does its fancy stuff like
gathering the media IDs and clearing the playlist, but instead
of generating the playlist file there we use the Stream_Playlist
class to store the list of URLs in the database, then redirect to
play/index.php to create the actual download (there are some magic
playlist types like localplay that don't need to redirect.)
The playlist will be cached as long as that stream session is active, so
it can be downloaded multiple times and by clients that don't share the
browser's cookie cache.
Clean up the playlist generation by reducing copypasta.
Diffstat (limited to 'stream.php')
-rw-r--r-- | stream.php | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -136,26 +136,26 @@ switch ($_REQUEST['action']) { break; case 'democratic': // Don't let them loop it + // FIXME: This looks hacky if (Config::get('play_type') == 'democratic') { Config::set('play_type', 'stream', true); } default: - if (Config::get('play_type') == 'stream') { + $stream_type = Config::get('play_type'); + if ($stream_type == 'stream') { $stream_type = Config::get('playlist_type'); } - else { - $stream_type = Config::get('play_type'); - } break; } -/* Start the Stream */ debug_event('stream.php' , 'Stream Type: ' . $stream_type . ' Media IDs: '. json_encode($media_ids), 5); -$stream = new Stream($stream_type, $media_ids); +$playlist = new Stream_Playlist(); +$playlist->add($media_ids); if (isset($urls)) { - $stream->add_urls($urls); + $playlist->add_urls($urls); } -$stream->start(); +// Depending on the stream type, will either generate a redirect or actually do +// the streaming. +$playlist->generate_playlist($stream_type, true); -} // end method switch ?> |