/** * stream * Streams a given media file. * Takes the file id in parameter with optional max bit rate, file format, time offset, size and estimate content length option. */ public static function stream($input) { self::check_version($input, "1.0.0", true); $fileid = self::check_parameter($input, 'id', true); $maxBitRate = $input['maxBitRate']; $format = $input['format']; // mp3, flv or raw $timeOffset = $input['timeOffset']; $size = $input['size']; // For video streaming. Not supported. $estimateContentLength = $input['estimateContentLength']; // Force content-length guessing if transcode $params = '&client=' . rawurlencode($input['c']) . '&noscrobble=1'; if ($estimateContentLength == 'true') { $params .= '&content_length=required'; } if ($format && $format != "raw") { $params .= '&transcode_to=' . $format; } if ($maxBitRate) { $params .= '&bitrate=' . $maxBitRate; } if ($timeOffset) { $params .= '&frame=' . $timeOffset; } $url = ''; if (Subsonic_XML_Data::isVideo($fileid)) { $url = Video::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version')); } elseif (Subsonic_XML_Data::isSong($fileid)) { $url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version')); } elseif (Subsonic_XML_Data::isPodcastEp($fileid)) { $url = Podcast_Episode::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version')); } if (!empty($url)) { self::follow_stream($url); } }