當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Stats::get_last_song方法代碼示例

本文整理匯總了PHP中Stats::get_last_song方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stats::get_last_song方法的具體用法?PHP Stats::get_last_song怎麽用?PHP Stats::get_last_song使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Stats的用法示例。


在下文中一共展示了Stats::get_last_song方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save_songplay

 /**
  * save_songplay
  * This takes care of queueing and then submitting the tracks.
  */
 public function save_songplay($song)
 {
     // Before we start let's pull the last song submitted by this user
     $previous = Stats::get_last_song($this->user_id);
     $diff = time() - $previous['date'];
     // Make sure it wasn't within the last min
     if ($diff < 60) {
         debug_event($this->name, 'Last song played within ' . $diff . ' seconds, not recording stats', '3');
         return false;
     }
     if ($song->time < 30) {
         debug_event($this->name, 'Song less then 30 seconds not queueing', '3');
         return false;
     }
     // Make sure there's actually a username and password before we keep going
     if (!$this->username || !$this->password) {
         debug_event($this->name, 'Username or password missing', '3');
         return false;
     }
     // Create our scrobbler with everything this time and then queue it
     $scrobbler = new scrobbler($this->username, $this->password, $this->hostname, $this->port, $this->path, $this->challenge, 'turtle.libre.fm');
     // Check to see if the scrobbling works
     if (!$scrobbler->queue_track($song->f_artist_full, $song->f_album_full, $song->title, time(), $song->time, $song->track)) {
         // Depending on the error we might need to do soemthing here
         return false;
     }
     // Go ahead and submit it now
     if (!$scrobbler->submit_tracks()) {
         debug_event($this->name, 'Error Submit Failed: ' . $scrobbler->error_msg, '3');
         if ($scrobbler->reset_handshake) {
             debug_event($this->name, 'Re-running Handshake due to error', '1');
             $this->set_handshake($this->user_id);
             // Try try again
             if ($scrobbler->submit_tracks()) {
                 return true;
             }
         }
         return false;
     }
     debug_event($this->name, 'Submission Successful', '5');
     return true;
 }
開發者ID:axelsimon,項目名稱:ampache,代碼行數:46,代碼來源:Librefm.plugin.php

示例2: save_mediaplay

 /**
  * save_songplay
  * This takes care of queueing and then submitting the tracks.
  */
 public function save_mediaplay($song)
 {
     // Only support songs
     if (strtolower(get_class($song)) != 'song') {
         return false;
     }
     // Make sure there's actually a session before we keep going
     if (!$this->challenge) {
         debug_event($this->name, 'Session key missing', '5');
         return false;
     }
     // Let's pull the last song submitted by this user
     $previous = Stats::get_last_song($this->user_id);
     $diff = time() - $previous['date'];
     // Make sure it wasn't within the last min
     if ($diff < 60) {
         debug_event($this->name, 'Last song played within ' . $diff . ' seconds, not recording stats', '3');
         return false;
     }
     if ($song->time < 30) {
         debug_event($this->name, 'Song less then 30 seconds not queueing', '3');
         return false;
     }
     // Create our scrobbler and then queue it
     $scrobbler = new scrobbler($this->api_key, $this->scheme, $this->api_host, $this->challenge, $this->secret);
     // Check to see if the scrobbling works by queueing song
     if (!$scrobbler->queue_track($song->f_artist_full, $song->f_album_full, $song->title, time(), $song->time, $song->track)) {
         return false;
     }
     // Go ahead and submit it now
     if (!$scrobbler->submit_tracks()) {
         debug_event($this->name, 'Error Submit Failed: ' . $scrobbler->error_msg, '3');
         return false;
     }
     debug_event($this->name, 'Submission Successful', '5');
     return true;
 }
開發者ID:cheese1,項目名稱:ampache,代碼行數:41,代碼來源:Lastfm.plugin.php

示例3: save_mediaplay

 /**
  * save_songplay
  * This takes care of queueing and then submitting the tracks.
  */
 public function save_mediaplay($song)
 {
     // Only support songs
     if (strtolower(get_class($song)) != 'song') {
         return false;
     }
     // Before we start let's pull the last song submitted by this user
     $previous = Stats::get_last_song($this->user_id);
     $user = new User($this->user_id);
     $diff = time() - $previous['date'];
     // Make sure it wasn't within the last 10sec
     if ($diff < 10) {
         debug_event($this->name, 'Last song played within ' . $diff . ' seconds, not recording stats', '3');
         return false;
     }
     // Make sure there's actually a server address before we keep going
     if (!$this->address) {
         debug_event($this->name, 'Server address missing', '3');
         return false;
     }
     $message = str_replace("%user", $user->fullname, $this->message);
     $message = str_replace("%artist", $song->f_artist_full, $message);
     $message = str_replace("%album", $song->f_album_full, $message);
     $message = str_replace("%title", $song->title, $message);
     $growl = $this->get_growl();
     $growl->notify('Now Playing', $message);
     debug_event($this->name, 'Submission Successful', '5');
     return true;
 }
開發者ID:nioc,項目名稱:ampache,代碼行數:33,代碼來源:Growl.plugin.php


注:本文中的Stats::get_last_song方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。