本文整理汇总了PHP中Playlist类的典型用法代码示例。如果您正苦于以下问题:PHP Playlist类的具体用法?PHP Playlist怎么用?PHP Playlist使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Playlist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addVideo
/**
* Adds video to database.
*/
function addVideo()
{
$id = checkVideoExists();
$addVideo = new addVideo();
$playlistClass = new Playlist();
$playlist = $playlistClass->getMatchedPlaylist($id);
$addVideo->addVideoByID($id, $playlist);
}
示例2: executeCreate
public function executeCreate(sfWebRequest $request)
{
$playlist = Doctrine::getTable('Playlist')->findOneByTitle($request->getPostParameter("title"));
if ($playlist == NULL) {
$playlist = new Playlist();
$playlist->title = $request->getPostParameter("title");
$playlist->save();
echo $playlist->getId();
} else {
echo 'error';
}
exit;
}
示例3: run
public function run()
{
$model = new Playlist();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Playlist'])) {
$model->attributes = $_POST['Playlist'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: parse
public function parse($content)
{
$data = $this->content2Data($content);
$version = 3;
$mediaSequence = 0;
extract($data);
// to $version, $mediaSequence, $targetDuration
$playlist = new Playlist();
foreach ($data['playlist'] as $index => $row) {
$mediaSegment = new Segment($row['uri'], $row['duration'], $mediaSequence + $index, !empty($row['isDiscontinuity']));
$playlist->add($mediaSegment);
}
return new M3U8($playlist, $version, $targetDuration, null, $allowCache, $hasEndlist);
}
示例5: admin
private function admin()
{
$today = strtotime('today');
$month = strtotime('first day of this month');
$last30 = strtotime('-30 days');
// Users statistics
$users['today'] = number_format(User::whereGt('reg_date', $today)->count());
$users['month'] = number_format(User::whereGt('reg_date', $month)->count());
$users['last30'] = number_format(User::whereGt('reg_date', $last30)->count());
$users['total'] = number_format(User::count());
View::set('users', $users);
// Playlists statistics
$playlists['today'] = number_format(Playlist::whereGt('date', $today)->count());
$playlists['month'] = number_format(Playlist::whereGt('date', $month)->count());
$playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count());
$playlists['total'] = number_format(Playlist::count());
View::set('playlists', $playlists);
// Tracks statistics
$tracks = number_format(Track::count());
View::set('tracks', $tracks);
// Tags statistics
$tags = number_format(Tag::count());
View::set('tags', $tags);
// Comments statistics
$comments = number_format(Comment::count());
View::set('comments', $comments);
// Likes
$likes = number_format(PlaylistLike::count());
View::set('likes', $likes);
// Reports
$reports = number_format(Report::count());
View::set('reports', $reports);
View::show('admin/admin');
}
示例6: testAddAndRemovePlaylist
function testAddAndRemovePlaylist()
{
// Create a playlist
$playlist = new Playlist();
$playlist->create("Scheduler Unit Test " . uniqid());
$result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
if (PEAR::isError($this->groupIdCreated)) {
$this->fail("Failed to create scheduled item: " . $this->groupIdCreated->getMessage());
}
$group = new ScheduleGroup($this->groupIdCreated);
if ($group->count() != 3) {
$this->fail("Wrong number of items added.");
}
$items = $group->getItems();
if (!is_array($items) || $items[1]["starts"] != "2010-11-11 01:30:34.231") {
$this->fail("Wrong start time for 2nd item.");
}
$result = $group->remove();
if ($result != 1) {
$this->fail("Did not remove item.");
}
Playlist::Delete($playlist->getId());
}
示例7: showPlaylistItem
private function showPlaylistItem(Playlist $item)
{
$donwloadLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DOWNLOAD . '&download=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id();
$itemLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_OPEN . '&playlist=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id();
$deleteLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DELETE . '&path=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id();
$itemName = $item->getName() != null ? $item->getName() . " (" . utf8_decode($item->getFilename()) . ")" : utf8_decode($item->getFilename());
echo ' <td width="24px"><img width="22px" height="22px" src="../resources/playlist/video.png" style="border:0px;" /></td>' . "\n";
echo ' <td><a href="' . $itemLink . '">' . htmlentities($itemName) . '</a></td>' . "\n";
echo ' <td width="24px"><a href="' . $donwloadLink . '" target="_blank"><img width="22px" height="22px" src="../resources/playlist/video_down.png" style="border:0px;" alt="Donwload Playlist" title="Donwload Playlist" /></a></td>' . "\n";
echo ' <td width="24px"><a href="' . $itemLink . '"><img width="22px" height="22px" src="../resources/playlist/view.png" style="border:0px;" alt="Open Playlist" title="Open Playlist" /></a></td>' . "\n";
echo ' <td width="24px"><img width="22px" height="22px" src="../resources/playlist/edit.png" style="border:0px;" alt="Edit Playlist" title="Edit Playlist" /></td>' . "\n";
echo ' <td width="24px"><a href="' . $deleteLink . '"><img width="22px" height="22px" src="../resources/playlist/remove.png" style="border:0px;" alt="Remove Playlist" title="Remove Playlist"
onclick="return confirm(\'Are you sure to delete playlist ' . htmlentities(utf8_decode($item->getFilename())) . '?\');" /></a></td>' . "\n";
}
示例8: add
/**
* Add a music clip or playlist to the schedule.
*
* @param int $p_showInstance
* ID of the show.
* @param $p_datetime
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
* @param $p_audioFileId
* (optional, either this or $p_playlistId must be set) DB ID of the audio file
* @param $p_playlistId
* (optional, either this of $p_audioFileId must be set) DB ID of the playlist
* @param $p_options
* Does nothing at the moment.
*
* @return int|PEAR_Error
* Return PEAR_Error if the item could not be added.
* Error code 555 is a scheduling conflict.
*/
public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null)
{
global $CC_CONFIG, $CC_DBC;
if (!is_null($p_audioFileId)) {
// Schedule a single audio track
// Load existing track
$track = StoredFile::Recall($p_audioFileId);
if (is_null($track)) {
return new PEAR_Error("Could not find audio track.");
}
// Check if there are any conflicts with existing entries
$metadata = $track->getMetadata();
$length = $metadata['MDATA_KEY_DURATION'];
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
// Insert into the table
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$sql = "INSERT INTO " . $CC_CONFIG["scheduleTable"] . " (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)" . " VALUES ({$p_showInstance}, TIMESTAMP '{$p_datetime}', " . " (TIMESTAMP '{$p_datetime}' + INTERVAL '{$length}')," . " '{$length}'," . " {$this->groupId}, {$p_audioFileId}, '{$length}')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
//var_dump($sql);
return $result;
}
} elseif (!is_null($p_playlistId)) {
// Schedule a whole playlist
// Load existing playlist
$playlist = Playlist::Recall($p_playlistId);
if (is_null($playlist)) {
return new PEAR_Error("Could not find playlist.");
}
// Check if there are any conflicts with existing entries
$length = trim($playlist->getLength());
//var_dump($length);
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
// Insert all items into the schedule
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$itemStartTime = $p_datetime;
$plItems = $playlist->getContents();
//var_dump($plItems);
foreach ($plItems as $row) {
$trackLength = $row["cliplength"];
//var_dump($trackLength);
$sql = "INSERT INTO " . $CC_CONFIG["scheduleTable"] . " (instance_id, playlist_id, starts, ends, group_id, file_id," . " clip_length, cue_in, cue_out, fade_in, fade_out)" . " VALUES ({$p_showInstance}, {$p_playlistId}, TIMESTAMP '{$itemStartTime}', " . " (TIMESTAMP '{$itemStartTime}' + INTERVAL '{$trackLength}')," . " '{$this->groupId}', '{$row['file_id']}', '{$trackLength}', '{$row['cuein']}'," . " '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
//var_dump($sql);
return $result;
}
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '{$itemStartTime}' + INTERVAL '{$trackLength}'");
}
}
RabbitMq::PushSchedule();
return $this->groupId;
}
示例9: index
function index()
{
$userid = $this->session->userdata('userid');
$this->load->static_model('Playlist');
$playlists = Playlist::getUsersPlaylists($userid);
$data = array('userid' => $userid, 'user' => $userid ? new User($userid) : NULL, 'playlists' => $playlists, 'page_title' => "Register");
$this->load->view("common/header.php", $data);
$this->load->view("register/register_view.php");
$this->load->view("common/footer.php");
}
示例10: is_logged
public function is_logged()
{
$user = Session::get('user');
if (isset($user)) {
$playlist = Playlist::get_for_display($user->get_id_user_lif());
Session::put('playlist', $playlist);
return $user;
} else {
return false;
}
}
示例11: addPlaylist
/**
* Add a playlist
*
* @param playlist_name str: new playlist name
* @param scan_id int: the scan id for a service scanner
* @param service_name str: the name of the service this playlist comes from eg.itunes
* @param service_unique_id str: any metadata key string to make the playlist more unique
* @return int: insert row id
*/
public function addPlaylist($playlist_name, $scan_id = 0, $service_name = null, $service_unique_id = null)
{
$playlist = new Playlist();
if ($scan_id > 0) {
$playlist->scan_id = (int) $scan_id;
}
if (strlen($service_name) > 0) {
$playlist->service_name = $service_name;
}
if (strlen($service_unique_id) > 0) {
$playlist->service_unique_id = $service_unique_id;
}
$playlist->name = $playlist_name;
$playlist->mtime = time();
$playlist->save();
$id = $playlist->getId();
$playlist->free();
unset($playlist);
return (int) $id;
}
示例12: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*/
public function loadModel()
{
if ($this->_model === null) {
if (isset($_GET['id'])) {
$this->_model = Playlist::model()->findbyPk($_GET['id']);
}
if ($this->_model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->_model;
}
示例13: setup
function setup()
{
global $CC_CONFIG, $CC_DBC;
// Clear the files table
$sql = "DELETE FROM " . $CC_CONFIG["filesTable"];
$CC_DBC->query($sql);
// Add a file
$values = array("filepath" => dirname(__FILE__) . "/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false);
// Add a file
$values = array("filepath" => dirname(__FILE__) . "/test10002.mp3");
$this->storedFile2 = StoredFile::Insert($values, false);
// Clear the schedule table
$sql = "DELETE FROM " . $CC_CONFIG["scheduleTable"];
$CC_DBC->query($sql);
// Create a playlist
$playlist = new Playlist();
$playlist->create("Scheduler Unit Test");
$result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
// Schedule it
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
}
示例14: generateId
public static function generateId($length)
{
$idExists = true;
while ($idExists) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$id = '';
for ($i = 0; $i < $length; $i++) {
$id .= $chars[rand(0, strlen($chars) - 1)];
}
$idExists = Playlist::exists(array('id' => $id));
}
return $id;
}
示例15: feedPlaylists
/**
* Feed playlists
*/
public function feedPlaylists()
{
$rows = $this->hasMany('UserRelation', 'follower')->where('active', 1)->select('leader')->findArray();
if (!$rows) {
return false;
}
// A little eager loading
$following = array();
foreach ($rows as $item) {
$following[] = $item['leader'];
}
return Playlist::tableAlias('p')->selectMany('p.*', 'username')->join('user', 'u.id = user_id', 'u')->where('p.published', 1)->whereIn('user_id', $following)->orderByDesc('p.id')->paginate();
}