本文整理汇总了PHP中Playlist::get_random_items方法的典型用法代码示例。如果您正苦于以下问题:PHP Playlist::get_random_items方法的具体用法?PHP Playlist::get_random_items怎么用?PHP Playlist::get_random_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist::get_random_items方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
foreach ($items as $item) {
$media_ids[] = array('object_type' => $item['object_type'], 'object_id' => $item['object_id']);
}
break;
case 'playlist_random':
$playlist = new Playlist($_REQUEST['playlist_id']);
$media_ids = $playlist->get_random_items();
break;
case 'random':
$matchlist = array();
if ($_REQUEST['genre'][0] != '-1') {
$matchlist['genre'] = $_REQUEST['genre'];
}
if ($_REQUEST['catalog'] != '-1') {
$matchlist['catalog'] = $_REQUEST['catalog'];
}
/* Setup the options array */
$options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type'], 'size_limit' => $_REQUEST['size_limit']);
$media_ids = get_random_songs($options, $matchlist);
break;
case 'democratic':
$democratic = new Democratic($_REQUEST['democratic_id']);
示例2: get_next_object
/**
* get_next_object
* This returns the next object in the tmp_playlist.
* Most of the time this will just be the top entry, but if there is a
* base_playlist and no items in the playlist then it returns a random
* entry from the base_playlist
*/
public function get_next_object($offset = 0)
{
// FIXME: Shouldn't this return object_type?
$offset = intval($offset);
$items = $this->get_items($offset + 1);
if (count($items) > $offset) {
return $items[$offset]['object_id'];
}
// If nothing was found and this is a voting playlist then get
// from base_playlist
if ($this->base_playlist) {
$base_playlist = new Playlist($this->base_playlist);
$data = $base_playlist->get_random_items(1);
return $data[0]['object_id'];
} else {
$sql = "SELECT `id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
return $results['id'];
}
}
示例3: explode
}
}
break;
case 'artist_random':
case 'tag_random':
$data = explode('_', $_REQUEST['type']);
$type = $data['0'];
$object = new $type($_REQUEST['id']);
$songs = $object->get_random_songs();
foreach ($songs as $song_id) {
$GLOBALS['user']->playlist->add_object($song_id, 'song');
}
break;
case 'playlist_random':
$playlist = new Playlist($_REQUEST['id']);
$items = $playlist->get_random_items();
foreach ($items as $item) {
$GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
}
break;
case 'clear_all':
$GLOBALS['user']->playlist->clear();
break;
}
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
/* Setting ratings */
/* Setting ratings */
case 'set_rating':
if (User::is_registered()) {
示例4: setPlayQueue
public static function setPlayQueue(SimpleXMLElement $xml, $type, $playlistID, $uri, $key, $shuffle)
{
$GLOBALS['user']->playlist->clear();
$id = 0;
if (!empty($key)) {
$id = self::getKeyFromMetadataUri($key);
} elseif (!empty($uri)) {
$key = self::getKeyFromFullUri($uri);
$id = self::getKeyFromMetadataUri($key);
}
$plmedias = array();
if ($id) {
if ($type == 'audio' || $type == 'video') {
$item = self::createLibraryItem($id);
if ($item != null) {
$plmedias = $item->get_medias();
}
}
} else {
// Add complete playlist
if (self::isPlaylist($playlistID)) {
$playlist = new Playlist(self::getAmpacheId($playlistID));
if ($shuffle) {
$plmedias = $playlist->get_random_items();
} else {
$plmedias = $playlist->get_items();
}
}
}
$GLOBALS['user']->playlist->add_medias($plmedias);
self::setTmpPlayQueue($xml, 1);
}