本文整理汇总了PHP中Song::get_stream_types_for_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::get_stream_types_for_type方法的具体用法?PHP Song::get_stream_types_for_type怎么用?PHP Song::get_stream_types_for_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::get_stream_types_for_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'];
}
//.........这里部分代码省略.........
示例2: get_stream_types
/**
* Get stream types.
* @return array
*/
public function get_stream_types($player = null)
{
return Song::get_stream_types_for_type($this->type, $player);
}
示例3: 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;
}
}
}
}
//.........这里部分代码省略.........
示例4: addVideo
public static function addVideo($xml, $video)
{
$xvideo = $xml->addChild('video');
$xvideo->addAttribute('id', self::getVideoId($video->id));
$xvideo->addAttribute('title', $video->f_full_title);
$xvideo->addAttribute('isDir', 'false');
$xvideo->addAttribute('coverArt', self::getVideoId($video->id));
$xvideo->addAttribute('isVideo', 'true');
$xvideo->addAttribute('type', 'video');
$xvideo->addAttribute('duration', $video->time);
if ($video->year > 0) {
$xvideo->addAttribute('year', $video->year);
}
$tags = Tag::get_object_tags('video', $video->id);
if (count($tags) > 0) {
$xvideo->addAttribute('genre', $tags[0]['name']);
}
$xvideo->addAttribute('size', $video->size);
$xvideo->addAttribute('suffix', $video->type);
$xvideo->addAttribute('contentType', $video->mime);
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
$path = basename($video->file);
$xvideo->addAttribute('path', $path);
// Set transcoding information if required
$transcode_cfg = AmpConfig::get('transcode');
$valid_types = Song::get_stream_types_for_type($video->type, 'api');
if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && !in_array('native', $valid_types)) {
$transcode_settings = $video->get_transcode_settings(null, 'api');
if ($transcode_settings) {
$transcode_type = $transcode_settings['format'];
$xvideo->addAttribute('transcodedSuffix', $transcode_type);
$xvideo->addAttribute('transcodedContentType', Video::type_to_mime($transcode_type));
}
}
}
示例5: get_stream_types
public function get_stream_types()
{
return Song::get_stream_types_for_type($this->type);
}