diff options
Diffstat (limited to 'lib/class/localplay.class.php')
-rw-r--r-- | lib/class/localplay.class.php | 322 |
1 files changed, 161 insertions, 161 deletions
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 186bea7e..26b39aba 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -26,10 +26,10 @@ class Localplay { public $type; /* Built Variables */ - private $_function_map = array(); + private $_function_map = array(); private $_template; private $_preferences = array(); - private $_player; + private $_player; /** * Constructor @@ -37,7 +37,7 @@ class Localplay { * file for the specified type and attempts to load in the function * map, the preferences and the template */ - public function __construct($type) { + public function __construct($type) { $this->type = $type; @@ -47,12 +47,12 @@ class Localplay { /** * _get_info - * This functions takes the type and attempts to get all the + * This functions takes the type and attempts to get all the * information needed to load it. Will log errors if there are * any failures, fatal errors will actually return something to the * gui */ - private function _get_info() { + private function _get_info() { $this->_load_player(); @@ -63,29 +63,29 @@ class Localplay { * This returns true / false if the player load * failed / worked */ - public function player_loaded() { + public function player_loaded() { - if (is_object($this->_player)) { - return true; - } - else { - return false; - } + if (is_object($this->_player)) { + return true; + } + else { + return false; + } } // player_loaded /** * format - * This makes the localplay/plugin information - * human readable + * This makes the localplay/plugin information + * human readable */ - public function format() { + public function format() { - if (!is_object($this->_player)) { return false; } + if (!is_object($this->_player)) { return false; } - $this->f_name = ucfirst($this->type); - $this->f_description = $this->_player->get_description(); - $this->f_version = $this->_player->get_version(); + $this->f_name = ucfirst($this->type); + $this->f_description = $this->_player->get_description(); + $this->f_version = $this->_player->get_version(); } // format @@ -96,40 +96,40 @@ class Localplay { * Will interface with in order to make all this magical stuf work * all LocalPlay modules should be located in /modules/<name>/<name>.class.php */ - private function _load_player() { + private function _load_player() { - if (!$this->type) { return false; } + if (!$this->type) { return false; } $filename = Config::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php'; $include = require_once ($filename); - - if (!$include) { + + if (!$include) { /* Throw Error Here */ debug_event('localplay','Unable to load ' . $this->type . ' controller','2'); - return false; + return false; } // include - else { + else { $class_name = "Ampache" . $this->type; $this->_player = new $class_name(); - if (!($this->_player instanceof localplay_controller)) { - debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1'); - unset($this->_player); - return false; - } + if (!($this->_player instanceof localplay_controller)) { + debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1'); + unset($this->_player); + return false; + } } - + } // _load_player /** * format_name - * This function takes the track name and checks to see if 'skip' + * This function takes the track name and checks to see if 'skip' * is supported in the current player, if so it returns a 'skip to' * link, otherwise it returns just the text */ - public function format_name($name,$id) { + public function format_name($name,$id) { $name = scrub_out($name); - $name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id); + $name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id); return $name; } // format_name @@ -138,31 +138,31 @@ class Localplay { * get_controllers * This returns the controllers that are currently loaded into this instance */ - public static function get_controllers() { + public static function get_controllers() { /* First open the dir */ - $handle = opendir(Config::get('prefix') . '/modules/localplay'); - - if (!is_resource($handle)) { - debug_event('Localplay','Error: Unable to read localplay controller directory','1'); - return array(); + $handle = opendir(Config::get('prefix') . '/modules/localplay'); + + if (!is_resource($handle)) { + debug_event('Localplay','Error: Unable to read localplay controller directory','1'); + return array(); } - $results = array(); + $results = array(); - while ($file = readdir($handle)) { + while ($file = readdir($handle)) { - if (substr($file,-14,14) != 'controller.php') { continue; } + if (substr($file,-14,14) != 'controller.php') { continue; } /* Make sure it isn't a dir */ - if (!is_dir($file)) { + if (!is_dir($file)) { /* Get the basename and then everything before controller */ - $filename = basename($file,'.controller.php'); - $results[] = $filename; - } + $filename = basename($file,'.controller.php'); + $results[] = $filename; + } } // end while - return $results; + return $results; } // get_controllers @@ -171,14 +171,14 @@ class Localplay { * This returns true or false depending on if the specified controller * is currently enabled */ - public static function is_enabled($controller) { + public static function is_enabled($controller) { // Load the controller and then check for its preferences - $localplay = new Localplay($controller); - // If we can't even load it no sense in going on - if (!isset($localplay->_player)) { return false; } + $localplay = new Localplay($controller); + // If we can't even load it no sense in going on + if (!isset($localplay->_player)) { return false; } - return $localplay->_player->is_installed(); + return $localplay->_player->is_installed(); } // is_enabled @@ -187,48 +187,48 @@ class Localplay { * This runs the install for the localplay controller we've * currently got pimped out */ - public function install() { + public function install() { // Run the player's installer - $installed = $this->_player->install(); - - return $installed; + $installed = $this->_player->install(); + + return $installed; } // install /** * uninstall - * This runs the uninstall for the localplay controller we've + * This runs the uninstall for the localplay controller we've * currently pimped out */ - public function uninstall() { + public function uninstall() { // Run the players uninstaller - $this->_player->uninstall(); + $this->_player->uninstall(); // If its our current player, reset player to nothing - if (Config::get('localplay_controller') == $this->type) { - Preference::update('localplay_controller',$GLOBALS['user']->id,''); - } + if (Config::get('localplay_controller') == $this->type) { + Preference::update('localplay_controller',$GLOBALS['user']->id,''); + } - return true; + return true; } // uninstall /** * connect - * This function attempts to connect to the localplay + * This function attempts to connect to the localplay * player that we are using */ - public function connect() { + public function connect() { - if (!$this->_player->connect()) { + if (!$this->_player->connect()) { debug_event('localplay','Error Unable to connect, check ' . $this->type . ' controller','1'); return false; } return true; - + } // connect /** @@ -236,13 +236,13 @@ class Localplay { * This function passes NULL and calls the play function of the player * object */ - public function play() { - - if (!$this->_player->play()) { + public function play() { + + if (!$this->_player->play()) { debug_event('localplay','Error Unable to start playback, check ' . $this->type . ' controller','1'); return false; } - + return true; } // play @@ -252,9 +252,9 @@ class Localplay { * This functions passes NULl and calls the stop function of the player * object, it should recieve a true/false boolean value */ - public function stop() { + public function stop() { - if (!$this->_player->stop()) { + if (!$this->_player->stop()) { debug_event('localplay','Error Unable to stop playback, check ' . $this->type . ' controller','1'); return false; } @@ -266,48 +266,48 @@ class Localplay { /** * add * This function takes a single object and then passes it to - * to the player, this is a required function. + * to the player, this is a required function. */ - public function add($object) { + public function add($object) { - if (!$this->_player->add($object)) { + if (!$this->_player->add($object)) { debug_event('localplay','Error Unable to add songs, check ' . $this->type . ' controller','1'); return false; } - + return true; } // add /** - * add_url + * add_url * This directly adds an array of URLs to the localplay module. This is really how I should * have done add, will migrate to this eventually */ - public function add_url($urls) { + public function add_url($urls) { $function = $this->_function_map['add_url']; - - if (!$this->_player->$function($urls)) { + + if (!$this->_player->$function($urls)) { debug_event('localplay','Error Unable to add urls, check ' . $this->type . ' controller','1'); - return false; - } + return false; + } - return true; + return true; } // add_url /** * repeat - * This turns the repeat feature of a localplay method on or + * This turns the repeat feature of a localplay method on or * off, takes a 0/1 value */ - public function repeat($state) { + public function repeat($state) { $data = $this->_player->repeat($state); - if (!$data) { + if (!$data) { debug_event('localplay',"Error Unable to set Repeat to $state",'1'); } @@ -318,16 +318,16 @@ class Localplay { /** * random * This turns on the random feature of a localplay method - * It takes a 0/1 value + * It takes a 0/1 value */ - public function random($state) { - - $data = $this->_player->random($state); + public function random($state) { + + $data = $this->_player->random($state); - if (!$data) { + if (!$data) { debug_event('localplay',"Error Unable to set Random to $state",'1'); } - + return $data; } // random @@ -337,11 +337,11 @@ class Localplay { * This returns current information about the state of the player * There is an expected array format */ - public function status() { + public function status() { $data = $this->_player->status(); - if (!count($data)) { + if (!count($data)) { debug_event('localplay','Error Unable to get status, check ' . $this->type . ' controller','1'); return false; } @@ -356,15 +356,15 @@ class Localplay { * the array of current songs for display or whatever * an empty array is passed on failure */ - public function get() { + public function get() { $data = $this->_player->get(); - - if (!count($data) OR !is_array($data)) { + + if (!count($data) OR !is_array($data)) { debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1'); - return array(); + return array(); } - + return $data; } // get @@ -372,18 +372,18 @@ class Localplay { /** * volume_set * This isn't a required function, it sets the volume to a specified value - * as passed in the variable it is a 0 - 100 scale the controller is + * as passed in the variable it is a 0 - 100 scale the controller is * responsible for adjusting the scale if nessecary */ - public function volume_set($value) { - + public function volume_set($value) { + /* Make sure it's int and 0 - 100 */ $value = int($value); /* Make sure that it's between 0 and 100 */ if ($value > 100 OR $value < 0) { return false; } - if (!$this->_player->volume($value)) { + if (!$this->_player->volume($value)) { debug_event('localplay','Error: Unable to set volume, check ' . $this->type . ' controller','1'); return false; } @@ -397,11 +397,11 @@ class Localplay { * This function isn't required. It tells the daemon to increase the volume * by a pre-defined amount controlled by the controller */ - public function volume_up() { + public function volume_up() { - if (!$this->_player->volume_up()) { + if (!$this->_player->volume_up()) { debug_event('localplay','Error: Unable to increase volume, check ' . $this->type . ' controller','1'); - return false; + return false; } return true; @@ -413,12 +413,12 @@ class Localplay { * This function isn't required. It tells the daemon to decrese the volume * by a pre-defined amount controlled by the controller. */ - public function volume_down() { + public function volume_down() { - if (!$this->_player->volume_down()) { + if (!$this->_player->volume_down()) { debug_event('localplay','Error: Unable to decrese volume, check ' . $this->type . ' controller','1'); - return false; - } + return false; + } return true; @@ -429,14 +429,14 @@ class Localplay { * This function isn't required, It tells the daemon to mute all output * It's up to the controller to decide what that actually entails */ - public function volume_mute() { + public function volume_mute() { - if (!$this->_player->volume(0)){ + if (!$this->_player->volume(0)){ debug_event('localplay','Error: Unable to mute volume, check ' . $this->type . ' controller','1'); - return false; + return false; } - return true; + return true; } // volume_mute @@ -444,11 +444,11 @@ class Localplay { * skip * This isn't a required function, it tells the daemon to skip to the specified song */ - public function skip($track_id) { + public function skip($track_id) { - if (!$this->_player->skip($track_id)) { + if (!$this->_player->skip($track_id)) { debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1'); - return false; + return false; } return true; @@ -457,14 +457,14 @@ class Localplay { /** * next - * This isn't a required function, it tells the daemon to go to the next + * This isn't a required function, it tells the daemon to go to the next * song */ - public function next() { + public function next() { - if (!$this->_player->next()) { + if (!$this->_player->next()) { debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1'); - return false; + return false; } return true; @@ -476,10 +476,10 @@ class Localplay { * This isn't a required function, it tells the daemon to go the the previous * song */ - public function prev() { - + public function prev() { + - if (!$this->_player->prev()) { + if (!$this->_player->prev()) { debug_event('localplay','Error: Unable to skip to previous song, check ' . $this->type . ' controller','1'); return false; } @@ -508,11 +508,11 @@ class Localplay { * get_instances * This returns the instances of the current type */ - public function get_instances() { + public function get_instances() { - $instances = $this->_player->get_instances(); + $instances = $this->_player->get_instances(); - return $instances; + return $instances; } // get_instances @@ -520,11 +520,11 @@ class Localplay { * current_instance * This returns the UID of the current Instance */ - public function current_instance() { + public function current_instance() { - $data = $this->_player->get_instance(); + $data = $this->_player->get_instance(); - return $data['id']; + return $data['id']; } // current_instance @@ -532,11 +532,11 @@ class Localplay { * get_instance * This returns the specified instance */ - public function get_instance($uid) { + public function get_instance($uid) { - $data = $this->_player->get_instance($uid); - - return $data; + $data = $this->_player->get_instance($uid); + + return $data; } // get_instance @@ -544,11 +544,11 @@ class Localplay { * update_instance * This updates the specified instance with a named array of data (_POST most likely) */ - public function update_instance($uid,$data) { + public function update_instance($uid,$data) { - $data = $this->_player->update_instance($uid,$data); + $data = $this->_player->update_instance($uid,$data); - return $data; + return $data; } // update_instance @@ -556,9 +556,9 @@ class Localplay { * add_instance * This adds a new instance for the current controller type */ - public function add_instance($data) { + public function add_instance($data) { - $this->_player->add_instance($data); + $this->_player->add_instance($data); } // add_instance @@ -566,9 +566,9 @@ class Localplay { * delete_instance * This removes an instance (it actually calls the players function) */ - public function delete_instance($instance_uid) { + public function delete_instance($instance_uid) { - $this->_player->delete_instance($instance_uid); + $this->_player->delete_instance($instance_uid); } // delete_instance @@ -576,9 +576,9 @@ class Localplay { * set_active_instance * This sets the active instance of the localplay controller */ - public function set_active_instance($instance) { + public function set_active_instance($instance) { - $this->_player->set_active_instance($instance); + $this->_player->set_active_instance($instance); } // set_active_instance @@ -587,9 +587,9 @@ class Localplay { * This removes songs from the players playlist it takes a single ID as provided * by the get command */ - public function delete_track($object_id) { + public function delete_track($object_id) { - if (!$this->_player->delete_track($object_id)) { + if (!$this->_player->delete_track($object_id)) { debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1'); return false; } @@ -604,11 +604,11 @@ class Localplay { * This removes every song from the players playlist as defined by the delete_all function * map */ - public function delete_all() { + public function delete_all() { - if (!$this->_player->clear_playlist()) { + if (!$this->_player->clear_playlist()) { debug_event('localplay','Error: Unable to delete entire playlist, check ' . $this->type . ' controller','1'); - return false; + return false; } return true; @@ -617,12 +617,12 @@ class Localplay { /** * get_instance_fields - * This loads the fields from the localplay - * player and returns them + * This loads the fields from the localplay + * player and returns them */ - public function get_instance_fields() { + public function get_instance_fields() { - $fields = $this->_player->instance_fields(); + $fields = $this->_player->instance_fields(); return $fields; @@ -633,9 +633,9 @@ class Localplay { * This function returns a user friendly version * of the current player state */ - public function get_user_state($state) { - - switch ($state) { + public function get_user_state($state) { + + switch ($state) { case 'play': return _('Now Playing'); break; @@ -648,7 +648,7 @@ class Localplay { default: return _('Unknown'); break; - } // switch on state + } // switch on state } // get_user_state @@ -657,10 +657,10 @@ class Localplay { * This attempts to return a nice user friendly * currently playing string */ - public function get_user_playing() { + public function get_user_playing() { $status = $this->status(); - + /* Format the track name */ $track_name = $status['track_artist'] . ' - ' . $status['track_album'] . ' - ' . $status['track_title']; @@ -672,7 +672,7 @@ class Localplay { $track_name = "[" . $status['track'] . "] - " . $track_name; return $track_name; - + } // get_user_playing |