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


PHP Playlist::addTrack方法代码示例

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


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

示例1: getNextTrack

    }
    public function getNextTrack()
    {
        if ($this->hasNextElement()) {
            return $this->_list->getSongById(++$this->_currentTrack);
        }
        return false;
    }
    public function getCurrentTrack()
    {
        return $this->_list->getSongById($this->_currentTrack);
    }
    public function hasNextElement()
    {
        if ($this->_list->getSongById($this->_currentTrack + 1)) {
            return true;
        }
        return false;
    }
}
$song1 = new Song('title1', 'author1');
$song2 = new Song('title2', 'author2');
$song3 = new Song('title3', 'author3');
$playlist = new Playlist();
$playlist->addTrack($song1);
$playlist->addTrack($song2);
$playlist->addTrack($song3);
$playlistItterator = new PlaylistItterator($playlist);
while ($playlistItterator->hasNextElement()) {
    echo $playlistItterator->getNextTrack()->getTitle() . "<br />";
}
开发者ID:VoidWalker,项目名称:learning-project,代码行数:31,代码来源:itterator.php

示例2: set

 protected function set()
 {
     #find all the events for this day, as well as the event artists and tracks
     $query = $this->entityManager->createQuery('SELECT e,a FROM Event e JOIN e.artist a WHERE e.date LIKE :date');
     $query->setParameter("date", "%" . $this->date->format('m-d'));
     $events = $query->getResult();
     $artistRepository = $this->entityManager->getRepository('Artist');
     $artists = $artistRepository->findBy(array("hasTracks" => NULL));
     #do not show playlist while the cron hasn't set all artist tracks
     if (count($artists)) {
         return array("code" => 3, "status" => "No tracks for playlist found. Please try again later.");
     }
     #find tracks for each event artist and create a playlist with a track for each one of the artists
     foreach ($events as $event) {
         $artist = $event->getArtist() || next;
         #ignores events without artist
         #trackless artist will not enter the playlist
         if (!$artist->getTracks()->count()) {
             error_log("trackless: " . $artist->getName() . ". Not adding to playlist");
             continue;
         }
         $tracks = $artist->getUnPublishedTracks();
         #ignore artists with all the tracks already published
         if (!count($tracks)) {
             continue;
         }
         $track = array_shift($tracks);
         $event->setTrack($track);
         $track->assignToEvent($event);
         $this->entityManager->persist($track);
         $this->entityManager->persist($event);
         #add to playlist tracks
         array_push($this->tracks, $track);
     }
     #create new playlist from the tracks found
     if (count($this->tracks)) {
         $playlist = new \Playlist();
         $playlist->setDate($this->date);
         foreach ($this->tracks as $track) {
             $playlist->addTrack($track);
         }
         $this->entityManager->persist($playlist);
         //update db
         $this->entityManager->flush();
         //set the total tracks in the attribute
         $this->total = $this->total();
     }
     return 1;
 }
开发者ID:andreiamlm,项目名称:ThisDayInMusic,代码行数:49,代码来源:Playlist.php


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