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


PHP Artist::getList方法代码示例

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


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

示例1: function

//
//		artist/1/album			- list of albums for artist=1
//				page head=artist.artist, list head=null
//
//		artist/1/album/2/song	- list of songs for artist=1, album=2
//				page head=artist.artist, list head=album+stats
//
//		artist/1/album/2/song/3	- load all songs for artist=1, album=2, play song=3, go to nowplaying
//
// 		artist/1/song			- list of all songs for artist=1
//				page head=artist.artist, list head=null
// artist 					- list of artists
//
$klein->respond('GET', '/artist', function ($request, $response) {
    // get the list of artists
    $list = Artist::getList();
    // walk the array and construct URLs
    // The encoded URL value is actually "artist name|album title". The artist
    // name is included to ensure that albums with the same name are not
    // conflated and the pipe character is a delimiter
    array_walk($list, function (&$v, $k) {
        $v = array('name' => $v, 'url' => '/artist/' . Music::encode($v) . '/album');
    });
    $list = array_filter($list, function ($v) {
        return $v['name'] ? true : false;
    });
    return ListPage::render('Artists', null, false, false, $list);
});
// artist/1/album			- list of albums for artist=1
//
$klein->respond('GET', '/artist/[:artist]/album', function ($request, $response) {
开发者ID:monstergfx,项目名称:pi-music,代码行数:31,代码来源:artist.php

示例2: scanAll

 /**
  * Scan the albums & artists in the music database and create artwork for
  * them.
  */
 public static function scanAll()
 {
     // get some config items
     $artwork_folder = Config::get('app.music-artwork-path');
     $artwork_sizes = array(180, 320);
     // get the music directory path
     $music_directory = Config::get('app.music-path');
     // get the list of artists
     $artists = Artist::getList();
     // step through the artists
     foreach ($artists as $artist) {
         // get the list of albums for the current artist
         $albums = Artist::getAlbums($artist);
         // step through the albums
         foreach ($albums as $album) {
             // create a file name for the  artist/album combination
             $image_file = md5($artist . $album['album']);
             // does the file already exist?
             if (!file_exists($artwork_folder . $image_file . '.jpg')) {
                 // No! we need to extract the artwork from a song file for
                 // this artist/album
                 // get the list of songs
                 $songs = Album::getSongs($artist, $album['album']);
                 // step through the songs & attempt to extract the image
                 //data
                 foreach ($songs as $song) {
                     // get the music file name
                     $music_file = $music_directory . $song['file'];
                     // make sure we have a music file to check
                     if (file_exists($music_file)) {
                         // get the image data (if we can)
                         $image = static::getImage($music_file);
                         // make sure we got an image
                         if ($image) {
                             // save the "untouched" image file
                             // save the original as a JPEG
                             imagejpeg($image, Config::get('app.music-artwork-path') . $image_file . ".jpg", 100);
                             // loop through the required sizes
                             foreach ($artwork_sizes as $s) {
                                 // resize to the appropriate size
                                 $i = static::resizeImage($image, $s);
                                 // and save
                                 if ($i) {
                                     imagejpeg($i, Config::get('app.music-artwork-path') . $image_file . "-{$s}.jpg", 100);
                                 }
                             }
                             // END loop through the required sizes
                             // all done with this one!
                             // break out of the song loop (since we
                             // don't need to scan any more songs from
                             // this album)
                             break;
                         }
                         // END make sure we got an image
                     }
                     // END make sure we have a music file to check
                 }
                 // END step through the songs
             }
             // END does the file already exist?
         }
         // END step through the albums
     }
     // END step through the artists
 }
开发者ID:monstergfx,项目名称:pi-music,代码行数:69,代码来源:Scan.php


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