本文整理汇总了PHP中Song类的典型用法代码示例。如果您正苦于以下问题:PHP Song类的具体用法?PHP Song怎么用?PHP Song使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Song类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSong
/**
* Add a song to the library
*
* @param artist_id int: the related artist primary key
* @param album_id int: the related album primary key
* @param genre_id int: the related genre primary key
* @param song_array array: the array of song info
* @return int: the song insert id
* @see apps/client/lib/MediaScan.class.php for information about the song_array
*/
public function addSong($artist_id, $album_id, $last_scan_id, $song_array)
{
if (isset($song_array['filename']) && !empty($song_array['filename']) && isset($song_array['mtime']) && !empty($song_array['mtime']) && $last_scan_id) {
$song = new Song();
$song->unique_id = sha1(uniqid('', true) . mt_rand(1, 99999999));
$song->artist_id = (int) $artist_id;
$song->album_id = (int) $album_id;
$song->scan_id = (int) $last_scan_id;
$song->name = $song_array['song_name'];
$song->length = $song_array['song_length'];
$song->accurate_length = (int) $song_array['accurate_length'];
$song->filesize = (int) $song_array['filesize'];
$song->bitrate = (int) $song_array['bitrate'];
$song->yearpublished = (int) $song_array['yearpublished'];
$song->tracknumber = (int) $song_array['tracknumber'];
$song->label = $song_array['label'];
$song->mtime = (int) $song_array['mtime'];
$song->atime = (int) $song_array['atime'];
$song->filename = $song_array['filename'];
$song->save();
$id = $song->getId();
$song->free();
unset($song, $song_array);
return $id;
}
return false;
}
示例2: getFileSafeTitle
/**
* File/Folder safe name of song
*
* @return string
* @throws SMException
*/
public function getFileSafeTitle()
{
if (empty($this->song)) {
throw new SMException('Song myst be set');
}
return Utility::GenerateSafeFileName($this->song->getTitle());
}
示例3: get_media_files
/**
* get_media_files
*
* Takes an array of media ids and returns an array of the actual filenames
*
* @param array $media_ids Media IDs.
*/
function get_media_files($media_ids)
{
$media_files = array();
$total_size = 0;
foreach ($media_ids as $element) {
if (is_array($element)) {
if (isset($element['object_type'])) {
$type = $element['object_type'];
$id = $element['object_id'];
} else {
$type = array_shift($element);
$id = array_shift($element);
}
$media = new $type($id);
} else {
$media = new Song($element);
}
if ($media->enabled) {
$media->format();
$total_size += sprintf("%.2f", $media->size / 1048576);
$dirname = '';
$parent = $media->get_parent();
if ($parent != null) {
$pobj = new $parent['object_type']($parent['object_id']);
$pobj->format();
$dirname = $pobj->get_fullname();
}
if (!array_key_exists($dirname, $media_files)) {
$media_files[$dirname] = array();
}
array_push($media_files[$dirname], Core::conv_lc_file($media->file));
}
}
return array($media_files, $total_size);
}
示例4: getSongs
public function getSongs($status)
{
if ($status == 'all') {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website ORDER BY title");
} elseif ($status == 'repertoire') {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe != 1 AND probe != 5 ORDER BY title");
} elseif ($status == 'uebrige') {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe != 1 AND probe != 5 ORDER BY g_id, title");
} elseif ($status == 'erschienen') {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website ORDER BY erschienen DESC");
} elseif ($status == 2) {
$dringend = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 3 ORDER BY title");
$proben = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 2 ORDER BY title");
$sonstige = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 4 ORDER BY letzteProbe");
$songs = array_merge($dringend, $proben, $sonstige);
} elseif ($status == 5) {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE\n angefangen > '" . date("Y-m-d", time() - 3600 * 24 * 21) . "' OR probe = '5' ORDER BY angefangen DESC");
} else {
$songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = '" . $status . "' ORDER BY title");
}
foreach ($songs as $song) {
$song['b'] = $song['c'];
$song['arr_b'] = $song['arr_c'];
$song['arr_t'] = '';
$song['arr_p'] = '';
$S = new Song();
$S->setSong($song);
$this->songs[$song['id']] = $S;
}
return $this->songs;
}
示例5: action_add_song
public function action_add_song()
{
$user = $this->is_logged();
if ($user === false) {
return Redirect::to_action('login');
} else {
$song = new Song();
$form = $_POST;
$song->set_id_kind(null);
if ($_POST['name'] != "") {
$song->set_title_song($_POST['name']);
} else {
$this->_error_form = true;
$this->_error_msg .= "Il y a une erreur dans le titre. </br>";
}
if (isset($_POST['genre'])) {
$song->set_id_kind($_POST['genre']);
} else {
$this->_error_form = true;
$this->_error_msg .= "Il faut sélectionner au moins 1 genre. </br>";
}
if (is_numeric($_POST['anneeF']) and preg_match("/^[0-2][0-9]{3}+\$/", $_POST['anneeF']) == 1) {
$song->set_date_song($_POST['anneeF']);
} else {
$this->_error_form = true;
$this->_error_msg .= "Le format de l'année n'est pas valable. (Format:AAAA). </br>";
}
if (is_numeric($_POST['num'])) {
$song->set_track_song($_POST['num']);
} else {
$this->_error_form = true;
$this->_error_msg .= "Le numéro dans l'album doit être numérique. </br>";
}
if (isset($_POST['path'])) {
$path = str_replace(' ', '_', $_POST['path']);
$song->set_path_song(str_replace('public', '', URL::base()) . 'song/' . $path);
} else {
$this->_error_form = true;
$this->_error_msg .= "Vous devez rentrez un fichier dans le formulaire de téléversement. </br>";
}
if ($this->_error_form == false) {
$song->set_length_song($_POST['lengthM'], $_POST['lengthS']);
}
//var_dump(isset($_POST['album']));
if (isset($_POST['album'])) {
$song->_id_album = $_POST['album'];
} else {
$this->_error_form = true;
$this->_error_msg .= "Ce groupe n'a pas encore d'album, veuillez le créer. </br>";
}
if ($this->_error_form == false and !$song->check_exists()) {
$song->set_id_user_lif($user->get_id_user_lif());
$song->add();
$this->_error_msg .= "Chanson ajoutée avec succés!";
$form = null;
}
return Redirect::to_action('song@add')->with('error', true)->with('form', $form)->with('error_msg', $this->_error_msg);
}
}
示例6: get
/**
* Get a song waveform.
* @param int $song_id
* @return binary|string|null
*/
public static function get($song_id)
{
$song = new Song($song_id);
$waveform = null;
if ($song->id) {
$song->format();
$waveform = $song->waveform;
if (!$waveform) {
$catalog = Catalog::create_from_id($song->catalog);
if ($catalog->get_type() == 'local') {
$transcode_to = 'wav';
$transcode_cfg = AmpConfig::get('transcode');
$valid_types = $song->get_stream_types();
if ($song->type != $transcode_to) {
$basedir = AmpConfig::get('tmp_dir_path');
if ($basedir) {
if ($transcode_cfg != 'never' && in_array('transcode', $valid_types)) {
$tmpfile = tempnam($basedir, $transcode_to);
$tfp = fopen($tmpfile, 'wb');
if (!is_resource($tfp)) {
debug_event('waveform', "Failed to open " . $tmpfile, 3);
return null;
}
$transcoder = Stream::start_transcode($song, $transcode_to);
$fp = $transcoder['handle'];
if (!is_resource($fp)) {
debug_event('waveform', "Failed to open " . $song->file . " for waveform.", 3);
return null;
}
do {
$buf = fread($fp, 2048);
fwrite($tfp, $buf);
} while (!feof($fp));
fclose($fp);
fclose($tfp);
Stream::kill_process($transcoder);
$waveform = self::create_waveform($tmpfile);
//$waveform = self::create_waveform("C:\\tmp\\test.wav");
@unlink($tmpfile);
} else {
debug_event('waveform', 'transcode setting to wav required for waveform.', '3');
}
} else {
debug_event('waveform', 'tmp_dir_path setting required for waveform.', '3');
}
} else {
$waveform = self::create_waveform($song->file);
}
}
if ($waveform) {
self::save_to_db($song_id, $waveform);
}
}
}
return $waveform;
}
示例7: isPercussionChannel
protected function isPercussionChannel(Song $song, $channelId)
{
$channels = $song->getChannels();
foreach ($channels as $channel) {
if ($channel->getChannelId() == $channelId) {
return $channel->isPercussionChannel();
}
}
return false;
}
示例8: get_current_slideshow
public static function get_current_slideshow()
{
$songs = Song::get_recently_played($GLOBALS['user']->id);
$images = array();
if (count($songs) > 0) {
$last_song = new Song($songs[0]['object_id']);
$last_song->format();
$images = self::get_images($last_song->f_artist);
}
return $images;
}
示例9: retrieveSongs
public function retrieveSongs()
{
global $db, $hades;
if ($this->itemsPerPage > 0) {
$modifier = $this->page - 1;
$offset = $modifier * $this->itemsPerPage;
$limit = 'LIMIT ' . $offset . ', ' . $this->itemsPerPage;
} else {
$limit = '';
}
try {
$statement = $db->prepare('
SELECT *
FROM songs ' . $limit);
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($results as $row) {
array_push($this->songs, Song::fillValues($row));
}
$total = $db->query('
SELECT *
FROM songs
');
$this->totalItems = $total->rowCount();
} catch (Exception $e) {
$hades->databaseError($e);
exit;
}
}
示例10: setSong
public function setSong($song)
{
parent::setSong($song);
$this->ps_id = $song['ps_id'];
$this->pl_id = $song['pl_id'];
$this->pb_id = $song['pb_id'];
$this->pl_datum = $song['pl_datum'];
$this->setPlayedButton();
}
示例11: execute
public function execute($smarty, $params, $session)
{
$smarty->assign('name', $session['screen_name']);
$artists = Artist::findAll();
$smarty->assign('artists', $artists);
$songs = Song::findAll();
$smarty->assign('songs', $songs);
$parts = Part::findAll();
$smarty->assign('parts', $parts);
$smarty->display('index.tpl');
}
示例12: home
/**
* Display a listing of the resource.
*
* @return Response
*/
public function home()
{
$banners = $this->banners;
$body = 'body goes here';
$header = 'Header goes here';
$tweets = Gtweet::get();
$videos = Video::wherePin(true)->get();
$songs = Song::get();
$projects = Project::limit(8)->latest()->get();
return View::make('pages.home')->with(compact('body', 'header', 'banners', 'tweets', 'videos', 'songs', 'projects'));
}
示例13: render
/**
* Render a list page
*
* @param Song $song
* The song that is currently playing
*
* @return string
* The HTML of the rendered page
*/
public static function render($song, $previous)
{
// instantiate the template engine
$parser = new Rain\Tpl();
// get the image data for the song
$image_data = Song::getImageData($song['Artist'], $song['Album'], 320);
// assign the values to the template parser
$parser->assign(array('image' => $image_data, 'song' => $song, 'volume' => Music::getVolume(), 'previous' => $previous));
// return the HTML
return $parser->draw("now-playing-page", true);
}
示例14: get_latest_songs
public function get_latest_songs($count)
{
if (!is_numeric($count)) {
Logger::log("get_latest_songs: invalid count value");
return array();
}
if (!$this->initialised()) {
Logger::log("get_latest_songs: user not initialised");
return array();
}
return Song::get_users_latest_songs($this, $count);
}
示例15: insertAndGet
public static function insertAndGet($pdo, $name, $artist)
{
$st = $pdo->prepare('select * from songs where name = ? and artist_id = ?');
$st->execute(array($name, $artist->id));
if ($row = $st->fetch()) {
return Song::factory($row);
} else {
$st = $pdo->prepare('insert into songs(name, artist_id) values(?, ?)');
$st->execute(array($name, $artist->id));
return self::insertAndGet($pdo, $name, $artist);
}
}