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


PHP Album::get_songs方法代码示例

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


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

示例1: gather_song_tags

 /**
  * Gather tags from audio files.
  * @param int $limit
  * @return array
  */
 public function gather_song_tags($limit = 5)
 {
     // We need the filenames
     $album = new Album($this->uid);
     // grab the songs and define our results
     $songs = $album->get_songs();
     $data = array();
     // Foreach songs in this album
     foreach ($songs as $song_id) {
         $song = new Song($song_id);
         $data = array_merge($data, $this->gather_media_tags($song));
         if ($limit && count($data) >= $limit) {
             return array_slice($data, 0, $limit);
         }
     }
     return $data;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:22,代码来源:art.class.php

示例2: Artist

     }
     break;
 case 'artist_random':
     $artist = new Artist($_REQUEST['artist_id']);
     $media_ids = $artist->get_random_songs();
     break;
 case 'album_random':
     $album = new Album($_REQUEST['album_id']);
     $media_ids = $album->get_random_songs();
     break;
 case 'album':
     debug_event('stream.php', 'Playing/Adding all songs of album(s) {' . $_REQUEST['album_id'] . '}...', '5');
     $albums_array = explode(',', $_REQUEST['album_id']);
     foreach ($albums_array as $a) {
         $album = new Album($a);
         $songs = $album->get_songs();
         foreach ($songs as $song) {
             $media_ids[] = array('object_type' => 'song', 'object_id' => $song);
         }
     }
     break;
 case 'playlist':
     $playlist = new Playlist($_REQUEST['playlist_id']);
     $songs = $playlist->get_songs();
     foreach ($songs as $song) {
         $media_ids[] = array('object_type' => 'song', 'object_id' => $song);
     }
     break;
 case 'smartplaylist':
     $playlist = new Search('song', $_REQUEST['playlist_id']);
     $items = $playlist->get_items();
开发者ID:axelsimon,项目名称:ampache,代码行数:31,代码来源:stream.php

示例3: album_songs

 /**
  * album_songs
  * This returns the songs of a specified album
  */
 public static function album_songs($input)
 {
     $album = new Album($input['filter']);
     $songs = $album->get_songs();
     // Set the offset
     XML_Data::set_offset($input['offset']);
     XML_Data::set_limit($input['limit']);
     ob_end_clean();
     echo XML_Data::songs($songs);
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:14,代码来源:api.class.php

示例4: update_single_item

 /**
  * update_single_item
  * updates a single album,artist,song from the tag data
  * this can be done by 75+
  */
 public static function update_single_item($type, $id)
 {
     // Because single items are large numbers of things too
     set_time_limit(0);
     $songs = array();
     switch ($type) {
         case 'album':
             $album = new Album($id);
             $songs = $album->get_songs();
             break;
         case 'artist':
             $artist = new Artist($id);
             $songs = $artist->get_songs();
             break;
         case 'song':
             $songs[] = $id;
             break;
     }
     // end switch type
     foreach ($songs as $song_id) {
         $song = new Song($song_id);
         $info = self::update_media_from_tags($song, '', '');
         if ($info['change']) {
             $file = scrub_out($song->file);
             echo "<dl>\n\t<dd>";
             echo "<strong>{$file} " . T_('Updated') . "</strong>\n";
             echo $info['text'];
             echo "\t</dd>\n</dl><hr align=\"left\" width=\"50%\" />";
             flush();
         } else {
             echo "<dl>\n\t<dd>";
             echo "<strong>" . scrub_out($song->file) . "</strong><br />" . T_('No Update Needed') . "\n";
             echo "\t</dd>\n</dl><hr align=\"left\" width=\"50%\" />";
             flush();
         }
     }
     // foreach songs
     self::gc();
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:44,代码来源:catalog.class.php

示例5: gather_tags

 /**
  * gather_tags
  * This looks for the art in the meta-tags of the file
  * itself
  */
 public function gather_tags($limit = 5)
 {
     // We need the filenames
     $album = new Album($this->uid);
     // grab the songs and define our results
     $songs = $album->get_songs();
     $data = array();
     // Foreach songs in this album
     foreach ($songs as $song_id) {
         $song = new Song($song_id);
         // If we find a good one, stop looking
         $getID3 = new getID3();
         try {
             $id3 = $getID3->analyze($song->file);
         } catch (Exception $error) {
             debug_event('getid3', $error->getMessage(), 1);
         }
         if (isset($id3['asf']['extended_content_description_object']['content_descriptors']['13'])) {
             $image = $id3['asf']['extended_content_description_object']['content_descriptors']['13'];
             $data[] = array('song' => $song->file, 'raw' => $image['data'], 'mime' => $image['mime']);
         }
         if (isset($id3['id3v2']['APIC'])) {
             // Foreach in case they have more then one
             foreach ($id3['id3v2']['APIC'] as $image) {
                 $data[] = array('song' => $song->file, 'raw' => $image['data'], 'mime' => $image['mime']);
             }
         }
         if ($limit && count($data) >= $limit) {
             return array_slice($data, 0, $limit);
         }
     }
     // end foreach
     return $data;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:39,代码来源:art.class.php

示例6: advanced


//.........这里部分代码省略.........
             $sql .= ' GROUP BY `album`.`id`';
             break;
         case 'artist':
             $sql = "SELECT `artist`.`id`, SUM(`song`.`size`) AS `size`, SUM(`song`.`time`) AS `time` FROM `artist` ";
             if (!$search_info || !$search_info['join']['song']) {
                 $sql .= "LEFT JOIN `song` ON `song`.`artist`=`artist`.`id` ";
             }
             if ($search_info) {
                 $sql .= $search_info['table_sql'];
             }
             if (AmpConfig::get('catalog_disable')) {
                 $sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
                 $sql .= " WHERE `catalog`.`enabled` = '1'";
             }
             if ($search_info) {
                 if (AmpConfig::get('catalog_disable')) {
                     $sql .= ' AND ' . $search_info['where_sql'];
                 } else {
                     $sql .= ' WHERE ' . $search_info['where_sql'];
                 }
             }
             $sql .= ' GROUP BY `artist`.`id`';
             break;
     }
     $sql .= " ORDER BY RAND() {$limit_sql}";
     // Run the query generated above so we can while it
     $db_results = Dba::read($sql);
     $results = array();
     $size_total = 0;
     $fuzzy_size = 0;
     $time_total = 0;
     $fuzzy_time = 0;
     while ($row = Dba::fetch_assoc($db_results)) {
         // If size limit is specified
         if ($data['size_limit']) {
             // Convert
             $new_size = $row['size'] / 1024 / 1024;
             // Only fuzzy 100 times
             if ($fuzzy_size > 100) {
                 break;
             }
             // Add and check, skip if over size
             if ($size_total + $new_size > $data['size_limit']) {
                 $fuzzy_size++;
                 continue;
             }
             $size_total = $size_total + $new_size;
             $results[] = $row['id'];
             // If we are within 4mb of target then jump ship
             if ($data['size_limit'] - floor($size_total) < 4) {
                 break;
             }
         }
         // if size_limit
         // If length really does matter
         if ($data['length']) {
             // base on min, seconds are for chumps and chumpettes
             $new_time = floor($row['time'] / 60);
             if ($fuzzy_time > 100) {
                 break;
             }
             // If the new one would go over skip!
             if ($time_total + $new_time > $data['length']) {
                 $fuzzy_time++;
                 continue;
             }
             $time_total = $time_total + $new_time;
             $results[] = $row['id'];
             // If there are less then 2 min of free space return
             if ($data['length'] - $time_total < 2) {
                 return $results;
             }
         }
         // if length does matter
         if (!$data['size_limit'] && !$data['length']) {
             $results[] = $row['id'];
         }
     }
     // end while results
     switch ($type) {
         case 'song':
             return $results;
         case 'album':
             $songs = array();
             foreach ($results as $result) {
                 $album = new Album($result);
                 $songs = array_merge($songs, $album->get_songs());
             }
             return $songs;
         case 'artist':
             $songs = array();
             foreach ($results as $result) {
                 $artist = new Artist($result);
                 $songs = array_merge($songs, $artist->get_songs());
             }
             return $songs;
         default:
             return false;
     }
 }
开发者ID:ivan801,项目名称:ampache,代码行数:101,代码来源:random.class.php

示例7: addShare

 public static function addShare($xml, $share)
 {
     $xshare = $xml->addChild('share');
     $xshare->addAttribute('id', $share->id);
     $xshare->addAttribute('url', $share->public_url);
     $xshare->addAttribute('description', $share->description);
     $user = new User($share->user);
     $xshare->addAttribute('username', $user->username);
     $xshare->addAttribute('created', date("c", $share->creation_date));
     if ($share->lastvisit_date > 0) {
         $xshare->addAttribute('lastVisited', date("c", $share->lastvisit_date));
     }
     if ($share->expire_days > 0) {
         $xshare->addAttribute('expires', date("c", $share->creation_date + $share->expire_days * 86400));
     }
     $xshare->addAttribute('visitCount', $share->counter);
     if ($share->object_type == 'song') {
         $song = new Song($share->object_id);
         self::addSong($xshare, $song, "entry");
     } elseif ($share->object_type == 'playlist') {
         $playlist = new Playlist($share->object_id);
         $songs = $playlist->get_songs();
         foreach ($songs as $id) {
             $song = new Song($id);
             self::addSong($xshare, $song, "entry");
         }
     } elseif ($share->object_type == 'album') {
         $album = new Album($share->object_id);
         $songs = $album->get_songs();
         foreach ($songs as $id) {
             $song = new Song($id);
             self::addSong($xshare, $song, "entry");
         }
     }
 }
开发者ID:nioc,项目名称:ampache,代码行数:35,代码来源:subsonic_xml_data.class.php

示例8: _musicChilds

 public static function _musicChilds($prmPath, $prmQuery, $start, $count)
 {
     $mediaItems = array();
     $maxCount = 0;
     $queryData = array();
     parse_str($prmQuery, $queryData);
     $parent = 'amp://music' . $prmPath;
     $pathreq = explode('/', $prmPath);
     if ($pathreq[0] == '' && count($pathreq) > 0) {
         array_shift($pathreq);
     }
     switch ($pathreq[0]) {
         case 'artists':
             switch (count($pathreq)) {
                 case 1:
                     // Get artists list
                     //$artists = Catalog::get_artists();
                     //list($maxCount, $artists) = self::_slice($artists, $start, $count);
                     $artists = Catalog::get_artists(null, $count, $start);
                     list($maxCount, $artists) = array(999999, $artists);
                     foreach ($artists as $artist) {
                         $artist->format();
                         $mediaItems[] = self::_itemArtist($artist, $parent);
                     }
                     break;
                 case 2:
                     // Get artist's albums list
                     $artist = new Artist($pathreq[1]);
                     if ($artist->id) {
                         $album_ids = $artist->get_albums();
                         list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count);
                         foreach ($album_ids as $album_id) {
                             $album = new Album($album_id);
                             $album->format();
                             $mediaItems[] = self::_itemAlbum($album, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'albums':
             switch (count($pathreq)) {
                 case 1:
                     // Get albums list
                     //!!$album_ids = Catalog::get_albums();
                     //!!list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count);
                     $album_ids = Catalog::get_albums($count, $start);
                     list($maxCount, $album_ids) = array(999999, $album_ids);
                     foreach ($album_ids as $album_id) {
                         $album = new Album($album_id);
                         $album->format();
                         $mediaItems[] = self::_itemAlbum($album, $parent);
                     }
                     break;
                 case 2:
                     // Get album's songs list
                     $album = new Album($pathreq[1]);
                     if ($album->id) {
                         $song_ids = $album->get_songs();
                         list($maxCount, $song_ids) = self::_slice($song_ids, $start, $count);
                         foreach ($song_ids as $song_id) {
                             $song = new Song($song_id);
                             $song->format();
                             $mediaItems[] = self::_itemSong($song, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'songs':
             switch (count($pathreq)) {
                 case 1:
                     // Get songs list
                     $catalogs = Catalog::get_catalogs();
                     foreach ($catalogs as $catalog_id) {
                         $catalog = Catalog::create_from_id($catalog_id);
                         $songs = $catalog->get_songs();
                         list($maxCount, $songs) = self::_slice($songs, $start, $count);
                         foreach ($songs as $song) {
                             $song->format();
                             $mediaItems[] = self::_itemSong($song, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'playlists':
             switch (count($pathreq)) {
                 case 1:
                     // Get playlists list
                     $pl_ids = Playlist::get_playlists();
                     list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count);
                     foreach ($pl_ids as $pl_id) {
                         $playlist = new Playlist($pl_id);
                         $playlist->format();
                         $mediaItems[] = self::_itemPlaylist($playlist, $parent);
                     }
                     break;
                 case 2:
                     // Get playlist's songs list
//.........这里部分代码省略.........
开发者ID:nioc,项目名称:ampache,代码行数:101,代码来源:upnp_api.class.php

示例9: switch

    }
} else {
    switch ($_REQUEST['action']) {
        case 'tmp_playlist':
            $media_ids = $GLOBALS['user']->playlist->get_items();
            $name = $GLOBALS['user']->username . ' - Playlist';
            break;
        case 'browse':
            $id = intval(scrub_in($_REQUEST['browse_id']));
            $browse = new Browse($id);
            $browse_media_ids = $browse->get_saved();
            foreach ($browse_media_ids as $media_id) {
                switch ($object_type) {
                    case 'album':
                        $album = new Album($media_id);
                        $media_ids = array_merge($media_ids, $album->get_songs());
                        break;
                    case 'song':
                        $media_ids[] = $media_id;
                        break;
                    case 'video':
                        $media_ids[] = array('object_type' => 'Video', 'object_id' => $media_id);
                        break;
                }
                // switch on type
            }
            // foreach media_id
            $name = 'Batch-' . date("dmY", time());
        default:
            // Rien a faire
            break;
开发者ID:cheese1,项目名称:ampache,代码行数:31,代码来源:batch.php


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