当前位置: 首页>>代码示例>>PHP>>正文


PHP Song::type_to_mime方法代码示例

本文整理汇总了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;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:24,代码来源:song_preview.class.php

示例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;
 }
开发者ID:nioc,项目名称:ampache,代码行数:60,代码来源:subsonic_xml_data.class.php


注:本文中的Song::type_to_mime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。