本文整理汇总了PHP中Song::get_transcode_settings方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::get_transcode_settings方法的具体用法?PHP Song::get_transcode_settings怎么用?PHP Song::get_transcode_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::get_transcode_settings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_types
protected static function get_types($item, $force_type = '')
{
$types = array('real' => 'mp3', 'player' => '');
$browsers = array_keys(self::browser_info());
$browser = '';
if (count($browsers) > 0) {
$browser = $browsers[0];
}
if (!empty($force_type)) {
debug_event("webplayer.class.php", "Forcing type to {" . $force_type . "}", 5);
$types['real'] = $force_type;
} else {
if ($browser == "msie" || $browser == "trident" || $browser == "webkit" || $browser == "safari") {
$types['real'] = "mp3";
} else {
$types['real'] = "ogg";
}
}
$song = null;
$urlinfo = Stream_URL::parse($item->url);
if ($urlinfo['id'] && $urlinfo['type'] == 'song') {
$song = new Song($urlinfo['id']);
} else {
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
$song = new Song_Preview($urlinfo['id']);
} else {
if (isset($urlinfo['demo_id'])) {
$democratic = new Democratic($urlinfo['demo_id']);
if ($democratic->id) {
$song_id = $democratic->get_next_object();
if ($song_id) {
$song = new Song($song_id);
}
}
}
}
}
if ($song != null) {
$ftype = $song->type;
$transcode = false;
$transcode_cfg = AmpConfig::get('transcode');
// Check transcode is required
$ftype_transcode = AmpConfig::get('transcode_' . $ftype);
$valid_types = Song::get_stream_types_for_type($ftype);
if ($transcode_cfg == 'always' || !empty($force_type) || $ftype_transcode == 'required' || $types['real'] != $ftype && !AmpConfig::get('webplayer_flash')) {
if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && in_array('transcode', $valid_types)) {
// Transcode only if excepted type available
$transcode_settings = $song->get_transcode_settings($types['real']);
if ($transcode_settings && AmpConfig::get('transcode_player_customize')) {
$transcode = true;
} else {
if (!in_array('native', $valid_types)) {
$transcode_settings = $song->get_transcode_settings(null);
if ($transcode_settings) {
$types['real'] = $transcode_settings['format'];
$transcode = true;
}
}
}
}
}
if (!$transcode) {
$types['real'] = $ftype;
}
if ($types['real'] == "flac" || $types['real'] == "ogg") {
$types['player'] = "oga";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4a";
}
}
} else {
if ($urlinfo['id'] && $urlinfo['type'] == 'video') {
$video = new Video($urlinfo['id']);
$types['real'] = pathinfo($video->file, PATHINFO_EXTENSION);
if ($types['real'] == "ogg") {
$types['player'] = "ogv";
} else {
if ($types['real'] == "webm") {
$types['player'] = "webmv";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4v";
}
}
}
} else {
if ($item->type == 'radio') {
$types['real'] = $item->codec;
if ($types['real'] == "flac" || $types['real'] == "ogg") {
$types['player'] = "oga";
}
} else {
$ext = pathinfo($item->url, PATHINFO_EXTENSION);
if (!empty($ext)) {
$types['real'] = $ext;
}
}
}
}
//.........这里部分代码省略.........
示例2: get_types
/**
* Get types information for an item.
* @param \playable_item $item
* @param string $force_type
* @return array
*/
protected static function get_types($item, $force_type = '')
{
$types = array('real' => 'mp3', 'player' => '');
$media = null;
$urlinfo = Stream_URL::parse($item->url);
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
$media = new $urlinfo['type']($urlinfo['id']);
} else {
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
$media = new Song_Preview($urlinfo['id']);
} else {
if (isset($urlinfo['demo_id'])) {
$democratic = new Democratic($urlinfo['demo_id']);
if ($democratic->id) {
$song_id = $democratic->get_next_object();
if ($song_id) {
$media = new Song($song_id);
}
}
}
}
}
if ($media != null) {
$ftype = $media->type;
$transcode = false;
$transcode_cfg = AmpConfig::get('transcode');
// Check transcode is required
$valid_types = Song::get_stream_types_for_type($ftype, 'webplayer');
if ($transcode_cfg == 'always' || !empty($force_type) || !in_array('native', $valid_types) || $types['real'] != $ftype && (!AmpConfig::get('webplayer_flash') || $urlinfo['type'] != 'song')) {
if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && in_array('transcode', $valid_types)) {
// Transcode forced from client side
if (!empty($force_type) && AmpConfig::get('transcode_player_customize')) {
debug_event("webplayer.class.php", "Forcing type to {" . $force_type . "}", 5);
// Transcode only if excepted type available
$transcode_settings = $media->get_transcode_settings($force_type, 'webplayer');
if ($transcode_settings) {
$types['real'] = $transcode_settings['format'];
$transcode = true;
}
}
// Transcode is not forced, transcode only if required
if (!$transcode) {
if (!in_array('native', $valid_types)) {
$transcode_settings = $media->get_transcode_settings(null, 'webplayer');
if ($transcode_settings) {
$types['real'] = $transcode_settings['format'];
$transcode = true;
}
}
}
}
}
if (!$transcode) {
$types['real'] = $ftype;
}
if ($urlinfo['type'] == 'song') {
if ($types['real'] == "ogg" || $types['real'] == "opus") {
$types['player'] = "oga";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4a";
}
}
} else {
if ($urlinfo['type'] == 'video') {
if ($types['real'] == "ogg") {
$types['player'] = "ogv";
} else {
if ($types['real'] == "webm") {
$types['player'] = "webmv";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4v";
}
}
}
}
}
} else {
if ($item->type == 'live_stream') {
$types['real'] = $item->codec;
if ($types['real'] == "ogg" || $types['real'] == "opus") {
$types['player'] = "oga";
}
} else {
$ext = pathinfo($item->url, PATHINFO_EXTENSION);
if (!empty($ext)) {
$types['real'] = $ext;
}
}
}
if (empty($types['player'])) {
$types['player'] = $types['real'];
}
//.........这里部分代码省略.........
示例3: play_url
/**
* 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);
}