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


PHP Track::structureData方法代码示例

本文整理汇总了PHP中Track::structureData方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::structureData方法的具体用法?PHP Track::structureData怎么用?PHP Track::structureData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track::structureData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Returns a specific user's track by it sequence number.
  *
  * @return mixed|bool track on success, or false on error.
  */
 public function get()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Track.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/DatabaseConnection.php';
     $connection = new DatabaseConnection();
     $query = $connection->prepare('SELECT `track`.`id`, `track`.`title`, `track`.`artist`, `artist`.`name` AS `artistName`, `track`.`album`, `album`.`name` AS `albumName`, `track`.`id` AS `file`, `playlist`.`userId` , `playlist`.`sequence`, `cover`.`albumId` AS `coverId` FROM `track`, `artist`, `playlist`, `album` LEFT JOIN `cover` ON `album`.`id`=`cover`.`albumId` AND `cover`.`status` = 1 WHERE `track`.`artist`=`artist`.`id` AND `track`.`album`=`album`.`id` AND `track`.`id`=`playlist`.`id` AND `playlist`.`userId`=:userId AND `playlist`.`sequence`=:sequence LIMIT 1;');
     $query->bindValue(':userId', $this->userId, PDO::PARAM_INT);
     $query->bindValue(':sequence', $this->sequence, PDO::PARAM_INT);
     $query->execute();
     $query->setFetchMode(PDO::FETCH_INTO, $this);
     if ($query->fetch()) {
         $trackStructured = new Track();
         //returns structured track
         return $trackStructured->structureData($this);
     }
     //returns false to indicate there is no such a track for this user
     return false;
 }
开发者ID:nioc,项目名称:web-music-player,代码行数:23,代码来源:Playlist.php

示例2: addFiles

 /**
  * Scan the specified folder and subfolders, insert in the library the files found.
  *
  * @param string $folder Root folder to scan
  *
  * @return array Tracks inserted
  */
 public function addFiles($folder)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Artist.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Album.php';
     $result = array();
     $this->scanFolders($folder, $this->folders);
     foreach ($this->files as $file) {
         //reset timeout for 20 seconds before processing each file
         set_time_limit(20);
         $track = new Track();
         $track->file = $file;
         $trackInfo = $track->readId3();
         if (key_exists('comments_html', $trackInfo)) {
             //ID3 has been found, we can use it
             if (key_exists('title', $trackInfo['comments_html'])) {
                 $track->title = $trackInfo['comments_html']['title'][0];
             }
             if (key_exists('album', $trackInfo['comments_html'])) {
                 $track->albumName = $trackInfo['comments_html']['album'][0];
             }
             if (key_exists('artist', $trackInfo['comments_html'])) {
                 $track->artistName = $trackInfo['comments_html']['artist'][0];
             }
             if (key_exists('track_number', $trackInfo['comments_html'])) {
                 $track->track = intval($trackInfo['comments_html']['track_number'][0]);
             }
             if (key_exists('year', $trackInfo['comments_html'])) {
                 $track->year = intval($trackInfo['comments_html']['year'][0]);
             }
             if (key_exists('audio', $trackInfo) && key_exists('bitrate_mode', $trackInfo['audio'])) {
                 $track->mode = $trackInfo['audio']['bitrate_mode'];
             }
             if (key_exists('audio', $trackInfo) && key_exists('bitrate', $trackInfo['audio'])) {
                 $track->bitrate = intval($trackInfo['audio']['bitrate']);
             }
             if (key_exists('playtime_seconds', $trackInfo)) {
                 $track->time = intval($trackInfo['playtime_seconds']);
             }
             if (key_exists('filesize', $trackInfo)) {
                 $track->size = intval($trackInfo['filesize']);
             }
         }
         if (!isset($track->title, $track->albumName, $track->artistName)) {
             //We use the filesystem pattern /path/artistName/albumName/title.ext
             $elements = explode('/', $file);
             $title = str_replace('-', ' ', str_replace('_', ' ', end($elements)));
             $albumName = str_replace('-', ' ', str_replace('_', ' ', prev($elements)));
             $artistName = str_replace('-', ' ', str_replace('_', ' ', prev($elements)));
             if (!isset($track->title)) {
                 $track->title = $title;
             }
             if (!isset($track->albumName)) {
                 $track->albumName = $albumName;
             }
             if (!isset($track->artistName)) {
                 $track->artistName = $artistName;
             }
         }
         //insert/update artist
         $artist = new Artist();
         $track->artist = $artist->insertIfRequired($track->artistName, null);
         //insert/update album
         $album = new Album();
         $track->album = $album->insertIfRequired($track->albumName, null, $track->artist);
         //insert track
         if ($track->insert()) {
             //add to the returned array
             array_push($result, $track->structureData($track));
         }
     }
     //return inserted files
     return $result;
 }
开发者ID:nioc,项目名称:web-music-player,代码行数:80,代码来源:Track.php

示例3: getTracks

 /**
  * Get album tracks.
  *
  * @return mixed Array of album tracks or false on failure
  */
 public function getTracks()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Track.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/DatabaseConnection.php';
     $connection = new DatabaseConnection();
     $query = $connection->prepare('SELECT `track`.`id`, `track`.`track`, `track`.`title`, `track`.`time`, `track`.`artist`, `artist`.`name` AS `artistName` FROM `track` INNER JOIN `artist` ON `artist`.`id` = `track`.`artist` WHERE `track`.`album` = :albumId  ORDER BY `track`.`track` ASC;');
     $query->bindValue(':albumId', $this->id, PDO::PARAM_INT);
     if ($query->execute()) {
         $this->tracks = $query->fetchAll(PDO::FETCH_CLASS);
         foreach ($this->tracks as $track) {
             $trackStructured = new Track();
             $track = $trackStructured->structureData($track);
         }
         //return album tracks
         return $this->tracks;
     }
     //returns database was not reachable
     return false;
 }
开发者ID:nioc,项目名称:web-music-player,代码行数:24,代码来源:Album.php


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