/** * 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); } }
public static function library_parts($params) { $n = count($params); if ($n > 0) { $key = $params[0]; if ($n == 2) { $file = $params[1]; $id = Plex_XML_Data::getAmpacheId($key); if (Plex_XML_Data::isSong($key)) { $media = new Song($id); if ($media->id) { $url = Song::play_url($id, '', 'api', true); self::stream_url($url); } else { self::createError(404); } } elseif (Plex_XML_Data::isVideo($key)) { $media = new Video($id); if ($media->id) { $url = Video::play_url($id, '', 'api', true); self::stream_url($url); } else { self::createError(404); } } } elseif ($n == 1) { if ($_SERVER['REQUEST_METHOD'] == 'PUT') { if (isset($_GET['subtitleStreamID'])) { $lang_code = dechex(hex2bin(substr($_GET['subtitleStreamID'], 0, 2))); $_SESSION['iframe']['subtitle'] = $lang_code; } } } } }
private static function _itemVideo($video, $parent) { $api_session = AmpConfig::get('require_session') ? Stream::get_session() : false; $art_url = Art::url($video->id, 'video', $api_session); $fileTypesByExt = self::_getFileTypes(); $arrFileType = $fileTypesByExt[$video->type]; return array('id' => $parent . '/' . $video->id, 'parentID' => $parent, 'restricted' => '1', 'dc:title' => self::_replaceSpecialSymbols($video->f_title), 'upnp:class' => isset($arrFileType['class']) ? $arrFileType['class'] : 'object.item.unknownItem', 'upnp:albumArtURI' => $art_url, 'upnp:genre' => Tag::get_display($video->tags, false, 'video'), 'res' => Video::play_url($video->id, '', 'api'), 'protocolInfo' => $arrFileType['mime'], 'size' => $video->size, 'duration' => $video->f_time_h . '.0'); }
if (AmpConfig::get('share')) { ?> <?php Share::display_ui('video', $video->id, false); ?> <?php } ?> <?php } ?> <?php if (Access::check_function('download')) { ?> <a rel="nohtml" href="<?php echo Video::play_url($video->id); ?> "><?php echo UI::get_icon('link', T_('Link')); ?> </a> <a rel="nohtml" href="<?php echo AmpConfig::get('web_path'); ?> /stream.php?action=download&video_id=<?php echo $video->id; ?> "><?php echo UI::get_icon('download', T_('Download')); ?> </a>
/** * videos * * This builds the xml document for displaying video objects * * @param array $videos (description here...) * @return string return xml */ public static function videos($videos) { if (count($videos) > self::$limit or self::$offset > 0) { $videos = array_slice($videos, self::$offset, self::$limit); } $string = ''; foreach ($videos as $video_id) { $video = new Video($video_id); $video->format(); $string .= "<video id=\"" . $video->id . "\">\n" . "\t<title><![CDATA[" . $video->title . "]]></title>\n" . "\t<mime><![CDATA[" . $video->mime . "]]></mime>\n" . "\t<resolution>" . $video->f_resolution . "</resolution>\n" . "\t<size>" . $video->size . "</size>\n" . self::tags_string($video->tags) . "\t<url><![CDATA[" . Video::play_url($video->id, '', 'api') . "]]></url>\n" . "</video>\n"; } // end foreach $final = self::_header() . $string . self::_footer(); return $final; }