Esempio n. 1
0
 /**
  * play_url
  * This returns a "PLAY" url for the video in question here, this currently feels a little
  * like a hack, might need to adjust it in the future
  */
 public static function play_url($oid, $additional_params = '', $sid = '', $force_http = '')
 {
     $video = new Video($oid);
     if (!$video->id) {
         return false;
     }
     $uid = intval($GLOBALS['user']->id);
     $oid = intval($video->id);
     $url = Stream::get_base_url() . "type=video&uid=" . $uid . "&oid=" . $oid;
     return Stream_URL::format($url . $additional_params);
 }
Esempio n. 2
0
 /**
  * play_url
  * This function takes all the song information and correctly formats a
  * a stream URL taking into account the downsmapling mojo and everything
  * else, this is the true function
  */
 public static function play_url($oid, $additional_params = '', $player = null, $local = false)
 {
     $song = new Song_Preview($oid);
     $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
     $type = $song->type;
     $song_name = rawurlencode($song->get_artist_name() . " - " . $song->title . "." . $type);
     $url = Stream::get_base_url($local) . "type=song_preview&oid=" . $song->id . "&uid=" . $user_id . "&name=" . $song_name;
     return Stream_URL::format($url . $additional_params);
 }
Esempio n. 3
0
 /**
  * play_url
  * This returns the special play URL for democratic play, only open to ADMINs
  */
 public function play_url()
 {
     $link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id);
     return Stream_URL::format($link);
 }
 public function generate_playlist($type, $redirect = false)
 {
     if (!count($this->urls)) {
         debug_event('stream_playlist', 'Error: Empty URL array for ' . $this->id, 2);
         return false;
     }
     debug_event('stream_playlist', 'Generating a {' . $type . '} object...', 5);
     $ext = $type;
     switch ($type) {
         case 'download':
         case 'democratic':
         case 'localplay':
         case 'web_player':
             // These are valid, but witchy
             $ct = "";
             $redirect = false;
             unset($ext);
             break;
         case 'asx':
             $ct = 'video/x-ms-wmv';
             break;
         case 'pls':
             $ct = 'audio/x-scpls';
             break;
         case 'ram':
             $ct = 'audio/x-pn-realaudio ram';
             break;
         case 'simple_m3u':
             $ext = 'm3u';
             $ct = 'audio/x-mpegurl';
             break;
         case 'xspf':
             $ct = 'application/xspf+xml';
             break;
         case 'm3u':
         default:
             // Assume M3U if the pooch is screwed
             $ext = $type = 'm3u';
             $ct = 'audio/x-mpegurl';
             break;
     }
     if ($redirect) {
         // Our ID is the SID, so we always want to include it
         AmpConfig::set('require_session', true, true);
         header('Location: ' . Stream::get_base_url() . 'uid=' . scrub_out($this->user) . '&type=playlist&playlist_type=' . scrub_out($type));
         exit;
     }
     if (isset($ext)) {
         header('Cache-control: public');
         header('Content-Disposition: filename=ampache_playlist.' . $ext);
         header('Content-Type: ' . $ct . ';');
     }
     $this->{'create_' . $type}();
 }
Esempio n. 5
0
 /**
  * Generate generic play url.
  * @param string $object_type
  * @param int $object_id
  * @param string $additional_params
  * @param boolean $local
  * @return string
  */
 public static function generic_play_url($object_type, $object_id, $additional_params, $player = null, $local = false)
 {
     $media = new $object_type($object_id);
     if (!$media->id) {
         return null;
     }
     $uid = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
     $type = $media->type;
     // Checking if the media is gonna be transcoded into another type
     // Some players doesn't allow a type streamed into another without giving the right extension
     $transcode_cfg = AmpConfig::get('transcode');
     $valid_types = Song::get_stream_types_for_type($type, $player);
     if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && !in_array('native', $valid_types)) {
         $transcode_settings = $media->get_transcode_settings(null);
         if ($transcode_settings) {
             debug_event("media", "Changing play url type from {" . $type . "} to {" . $transcode_settings['format'] . "} due to encoding settings...", 5);
             $type = $transcode_settings['format'];
         }
     }
     $media_name = $media->get_stream_name() . "." . $type;
     $media_name = str_replace("/", "-", $media_name);
     $media_name = str_replace("?", "", $media_name);
     $media_name = str_replace("#", "", $media_name);
     $media_name = rawurlencode($media_name);
     $url = Stream::get_base_url($local) . "type=" . $object_type . "&oid=" . $object_id . "&uid=" . $uid . $additional_params;
     if ($player) {
         $url .= "&player=" . $player;
     }
     $url .= "&name=" . $media_name;
     return Stream_URL::format($url);
 }
Esempio n. 6
0
 /**
  * play_url
  * This function takes all the song information and correctly formats a
  * a stream URL taking into account the downsmapling mojo and everything
  * else, this is the true function
  */
 public static function play_url($oid, $additional_params = '')
 {
     $song = new Song($oid);
     $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
     $type = $song->type;
     // Checking if the song is gonna be transcoded into another type
     // Some players doesn't allow a type streamed into another without giving the right extension
     $transcode_cfg = AmpConfig::get('transcode');
     $transcode_mode = AmpConfig::get('transcode_' . $type);
     if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && $transcode_mode == 'required') {
         $transcode_settings = $song->get_transcode_settings(null);
         if ($transcode_settings) {
             debug_event("song.class.php", "Changing play url type from {" . $type . "} to {" . $transcode_settings['format'] . "} due to encoding settings...", 5);
             $type = $transcode_settings['format'];
         }
     }
     $song_name = $song->get_artist_name() . " - " . $song->title . "." . $type;
     $song_name = str_replace("/", "-", $song_name);
     $song_name = str_replace("?", "", $song_name);
     $song_name = str_replace("#", "", $song_name);
     $song_name = rawurlencode($song_name);
     $url = Stream::get_base_url() . "type=song&oid=" . $song->id . "&uid=" . $user_id . $additional_params . "&name=" . $song_name;
     return Stream_URL::format($url);
 }