本文整理汇总了PHP中Playlist::add_medias方法的典型用法代码示例。如果您正苦于以下问题:PHP Playlist::add_medias方法的具体用法?PHP Playlist::add_medias怎么用?PHP Playlist::add_medias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist::add_medias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: playlists
public static function playlists($params)
{
$r = Plex_XML_Data::createContainer();
$n = count($params);
$createMode = $_SERVER['REQUEST_METHOD'] == 'POST';
$editMode = $_SERVER['REQUEST_METHOD'] == 'PUT';
$delMode = $_SERVER['REQUEST_METHOD'] == 'DELETE';
if ($createMode || $editMode || $delMode) {
self::check_access(50);
}
if ($n <= 1) {
$plid = 0;
if ($n == 0 && $createMode) {
// Create a new playlist
//$type = $_GET['type'];
$title = $_GET['title'];
//$smart = $_GET['smart'];
//$summary = $_GET['summary'];
$uri = $_GET['uri'];
$plid = Playlist::create($title, 'public');
$playlist = new Playlist($plid);
$key = Plex_XML_Data::getKeyFromFullUri($uri);
$id = Plex_XML_Data::getKeyFromMetadataUri($key);
if ($id) {
$item = Plex_XML_Data::createLibraryItem($id);
$medias = $item->get_medias();
$playlist->add_medias($medias);
}
$plid = Plex_XML_Data::getPlaylistId($plid);
} else {
if ($n == 1 && $params[0] != "all") {
$plid = $params[0];
}
}
if ($plid) {
if (Plex_XML_Data::isPlaylist($plid)) {
$playlist = new Playlist(Plex_XML_Data::getAmpacheId($plid));
if ($playlist->id) {
if ($delMode) {
// Delete playlist
$playlist->delete();
} else {
// Display playlist information
Plex_XML_Data::addPlaylist($r, $playlist);
}
}
}
} else {
// List all playlists
Plex_XML_Data::setPlaylists($r);
}
} elseif ($n >= 2) {
$plid = $params[0];
if (Plex_XML_Data::isPlaylist($plid) && $params[1] == "items") {
$playlist = new Playlist(Plex_XML_Data::getAmpacheId($plid));
if ($playlist->id) {
if ($n == 2) {
if ($editMode) {
// Add a new item to playlist
$uri = $_GET['uri'];
$key = Plex_XML_Data::getKeyFromFullUri($uri);
$id = Plex_XML_Data::getKeyFromMetadataUri($key);
if ($id) {
$item = Plex_XML_Data::createLibraryItem($id);
$medias = $item->get_medias();
$playlist->add_medias($medias);
Plex_XML_Data::addPlaylist($r, $playlist);
}
} else {
Plex_XML_Data::setPlaylistItems($r, $playlist);
}
} elseif ($n == 3) {
$index = intval($params[2]);
if ($delMode) {
$playlist->delete_track_number($index);
$playlist->regenerate_track_numbers();
exit;
}
}
}
}
}
Plex_XML_Data::setContainerSize($r);
self::apiOutputXml($r->asXML());
}
示例2: xoutput_from_array
}
$medias = array();
$item_id = $_REQUEST['item_id'];
$item_type = $_REQUEST['item_type'];
if (!empty($item_type) && Core::is_playable_item($item_type)) {
debug_event('playlist', 'Adding all medias of ' . $item_type . '(s) {' . $item_id . '}...', 5);
$item_ids = explode(',', $item_id);
foreach ($item_ids as $iid) {
$libitem = new $item_type($iid);
$medias = array_merge($medias, $libitem->get_medias());
}
} else {
debug_event('playlist', 'Adding all medias of current playlist...', 5);
$medias = $GLOBALS['user']->playlist->get_items();
}
if (count($medias) > 0) {
Ajax::set_include_override(true);
$playlist->add_medias($medias, true);
debug_event('playlist', 'Items added successfully!', '5');
ob_start();
display_notification(T_('Added to playlist'));
$results['rfc3514'] = ob_get_clean();
} else {
debug_event('playlist', 'No item to add. Aborting...', '5');
}
break;
default:
$results['rfc3514'] = '0x1';
break;
}
echo xoutput_from_array($results);