diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-15 16:16:04 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-15 16:16:04 +0000 |
commit | fdb7c58cb160c5f8f0f0327c11cba93226e062f6 (patch) | |
tree | 6cf57a740799a3a9b9dc9a035ccb66e1e54b053f /lib/class/stream.class.php | |
parent | 86ff429b366080b9203e5ddb1740339c64013853 (diff) | |
download | ampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.tar.gz ampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.tar.bz2 ampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.zip |
fix typo causing height to not display on art retrival, update to db allowing gc of tmp_browse, add extension to api album art image urls
Diffstat (limited to 'lib/class/stream.class.php')
-rw-r--r-- | lib/class/stream.class.php | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 5676490b..d4853780 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -722,14 +722,15 @@ class Stream { * This fucntion is used by the /play/index.php song * primarily, but could be used by other people */ - public static function insert_now_playing($song_id,$uid,$length,$sid,$type) { + public static function insert_now_playing($oid,$uid,$length,$sid,$type) { $time = time()+$length; $session_id = Dba::escape($sid); + $object_type = 'song'; // Do a replace into ensuring that this client always only has a single row - $sql = "REPLACE INTO `now_playing` (`id`,`song_id`, `user`, `expire`)" . - " VALUES ('$session_id','$song_id', '$uid', '$time')"; + $sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" . + " VALUES ('$session_id','$oid','$object_type', '$uid', '$time')"; $db_result = Dba::write($sql); } // insert_now_playing @@ -749,6 +750,54 @@ class Stream { } // clear_now_playing /** + * get_now_playing + * This returns the now playing information + */ + public static function get_now_playing($filter=NULL) { + + $sql = "SELECT `session_stream`.`agent`,`now_playing`.* " . + "FROM `now_playing` " . + "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " . + "ORDER BY `now_playing`.`expire` DESC"; + $db_results = Dba::read($sql); + + $results = array(); + + while ($row = Dba::fetch_assoc($db_results)) { + $type = $row['object_type']; + $media = new $type($row['object_id']); + $media->format(); + $client = new User($row['user']); + $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']); + } // end while + + return $results; + + } // get_now_playing + + /** + * check_lock_media + * This checks to see if the media is already being played, if it is then it returns false + * else return true + */ + public static function check_lock_media($media_id,$type) { + + $media_id = Dba::escape($media_id); + $type = Dba::escape($type); + + $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'"; + $db_results = Dba::read($sql); + + if (Dba::num_rows($db_results)) { + debug_event('Stream','Unable to play media currently locked by another user','3'); + return false; + } + + return true; + + } // check_lock_media + + /** * auto_init * This is called on class load it sets the session */ |