コード例 #1
0
ファイル: video.class.php プロジェクト: axelsimon/ampache
 /**
  * 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);
 }
コード例 #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);
 }
コード例 #3
0
ファイル: song.class.php プロジェクト: nioc/ampache
 /**
  * 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);
 }
コード例 #4
0
ファイル: democratic.class.php プロジェクト: cheese1/ampache
 /**
  * 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);
 }
コード例 #5
0
ファイル: song.class.php プロジェクト: axelsimon/ampache
 /**
  * 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);
 }