本文整理汇总了PHP中Track::getUserCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::getUserCollection方法的具体用法?PHP Track::getUserCollection怎么用?PHP Track::getUserCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::getUserCollection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: musicBrowser
function musicBrowser($type = "all", $page = 0, $display = 26, $genreid, $artistid, $albumid)
{
$result = array("tracks" => NULL);
$userid = $this->session->userdata('userid');
$genreid = $genreid == "all" ? NULL : $genreid;
$artistid = $artistid == "all" ? NULL : $artistid;
$albumid = $albumid == "all" ? NULL : $albumid;
if (!$userid) {
echo json_encode(array("error" => "You have to be logged in to view your music collection"));
return;
}
try {
if ($type == "genre") {
$mb_artists = Track::getUserArtists($userid, $genreid);
$mb_albums = Track::getUserAlbums($userid, $genreid, $artistid);
$result['artists'] = $mb_artists;
$result['albums'] = $mb_albums;
}
if ($type == "artist") {
$mb_albums = Track::getUserAlbums($userid, $genreid, $artistid);
$result['albums'] = $mb_albums;
}
$returned = Track::getUserCollection($userid, $page * $display, $display, $genreid, $artistid, $albumid);
} catch (Exception $e) {
echo json_encode(array("error" => $e->getMessage()));
return;
}
foreach ($returned['tracks'] as $track) {
$result['tracks'][] = $track->toArray();
}
$num_rows = $returned['rows'];
if ($num_rows > $display) {
$num_pages = ceil($num_rows / $display);
} else {
$num_pages = 1;
}
$result['num_pages'] = $num_pages;
$result['cur_page'] = $page;
echo json_encode($result);
}
示例2: getUserCollection
function getUserCollection($page = 0, $display = 26)
{
$userid = $this->session->userdata('userid');
$result_tracks = array();
if (!$userid) {
echo json_encode(array("error" => "User must be logged in to access her playlist."));
return;
}
try {
$returned = Track::getUserCollection($userid, $page * $display, $display);
} catch (Exception $e) {
echo json_encode(array("error" => $e->getMessage()));
return;
}
$tracks = $returned['tracks'];
$num_rows = $returned['rows'];
if ($num_rows > $display) {
$num_pages = ceil($num_rows / $display);
} else {
$num_pages = 1;
}
$newTracks = array();
foreach ($tracks as $track) {
$newTracks[] = $track->toArray();
}
$result = array("tracks" => $newTracks, "cur_page" => $page, "num_pages" => $num_pages);
echo json_encode($result);
}