本文整理汇总了PHP中Song::type_to_mime方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::type_to_mime方法的具体用法?PHP Song::type_to_mime怎么用?PHP Song::type_to_mime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::type_to_mime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* Song Preview class
*/
public function __construct($id = null)
{
if (!$id) {
return false;
}
$this->id = intval($id);
if ($info = $this->_get_info()) {
foreach ($info as $key => $value) {
$this->{$key} = $value;
}
$data = pathinfo($this->file);
$this->type = strtolower($data['extension']) ?: 'mp3';
$this->mime = Song::type_to_mime($this->type);
} else {
$this->id = null;
return false;
}
return true;
}
示例2: createSong
public static function createSong($xml, $song, $elementName = 'song')
{
$xsong = $xml->addChild(htmlspecialchars($elementName));
$xsong->addAttribute('id', self::getSongId($song->id));
$xsong->addAttribute('parent', self::getAlbumId($song->album));
//$xsong->addAttribute('created', );
$xsong->addAttribute('title', $song->title);
$xsong->addAttribute('isDir', 'false');
$xsong->addAttribute('isVideo', 'false');
$xsong->addAttribute('type', 'music');
$album = new Album($song->album);
$xsong->addAttribute('albumId', self::getAlbumId($album->id));
$xsong->addAttribute('album', $album->name);
$artist = new Artist($song->artist);
$xsong->addAttribute('artistId', self::getArtistId($song->artist));
$xsong->addAttribute('artist', $artist->name);
$xsong->addAttribute('coverArt', self::getAlbumId($album->id));
$xsong->addAttribute('duration', $song->time);
$xsong->addAttribute('bitRate', intval($song->bitrate / 1000));
$rating = new Rating($song->id, "song");
$user_rating = $rating->get_user_rating();
if ($user_rating > 0) {
$xsong->addAttribute('userRating', ceil($user_rating));
}
$avg_rating = $rating->get_average_rating();
if ($avg_rating > 0) {
$xsong->addAttribute('averageRating', ceil($avg_rating));
}
if ($song->track > 0) {
$xsong->addAttribute('track', $song->track);
}
if ($song->year > 0) {
$xsong->addAttribute('year', $song->year);
}
$tags = Tag::get_object_tags('song', $song->id);
if (count($tags) > 0) {
$xsong->addAttribute('genre', $tags[0]['name']);
}
$xsong->addAttribute('size', $song->size);
if ($album->disk > 0) {
$xsong->addAttribute('discNumber', $album->disk);
}
$xsong->addAttribute('suffix', $song->type);
$xsong->addAttribute('contentType', $song->mime);
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
$path = $artist->name . '/' . $album->name . '/' . basename($song->file);
$xsong->addAttribute('path', $path);
// Set transcoding information if required
$transcode_cfg = AmpConfig::get('transcode');
$valid_types = Song::get_stream_types_for_type($song->type, 'api');
if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && !in_array('native', $valid_types)) {
$transcode_settings = $song->get_transcode_settings(null, 'api');
if ($transcode_settings) {
$transcode_type = $transcode_settings['format'];
$xsong->addAttribute('transcodedSuffix', $transcode_type);
$xsong->addAttribute('transcodedContentType', Song::type_to_mime($transcode_type));
}
}
return $xsong;
}