From c603a3c5c098393e8aaa72e293daec5a431ee0c9 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 28 Mar 2006 07:00:32 +0000 Subject: fixed a minor flaging glitch --- modules/httpq/httpqplayer.class.php | 126 ++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 modules/httpq/httpqplayer.class.php (limited to 'modules/httpq/httpqplayer.class.php') diff --git a/modules/httpq/httpqplayer.class.php b/modules/httpq/httpqplayer.class.php new file mode 100644 index 00000000..8efaf6e4 --- /dev/null +++ b/modules/httpq/httpqplayer.class.php @@ -0,0 +1,126 @@ +host = $h; + $this->port = $p; + $this->password = $pw; + } // HttpQPlayer + + /*! + @function add + @discussion append a song to the playlist + @param $name Name to be shown in the playlist + @param $url URL of the song + */ + function add($name, $url) { + $args["name"] = $name; + $args["url"] = str_replace("&","%26",$url);; + $this->sendCommand("playurl", $args); + } + + /*! + @function clear + @discussion clear the playlist + */ + function clear() { + $args = array(); + $this->sendCommand("delete", $args); + } + + /*! + @function next + @discussion go to next song + */ + function next() { + $args = array(); + $this->sendCommand("next", $args); + } + + /*! + @function prev + @discussion go to previous song + */ + function prev() { + $args = array(); + $this->sendCommand("prev", $args); + } + + /*! + @function play + @discussion play the current song + */ + function play() { + $args = array(); + $this->sendCommand("play", $args); + } + + /*! + @function pause + @discussion toggle pause mode on current song + */ + function pause() { + $args = array(); + $this->sendCommand("pause", $args); + } + + /*! + @function stop + @discussion stop the current song + */ + function stop() { + $args = array(); + $this->sendCommand("stop", $args); + } + + function sendCommand($cmd, $args) { + $fp = fsockopen($this->host, $this->port, &$errno, &$errstr); + if(!$fp) { + debug_event('httpq',"HttpQPlayer: $errstr ($errno)",'1'); + } + else { + $msg = "GET /$cmd?p=$this->password"; + foreach ($args AS $key => $val) { + $msg = $msg . "&$key=$val"; + } + $msg = $msg . " HTTP/1.0\r\n\r\n"; + fputs($fp, $msg); + while(!feof($fp)) { + fgets($fp); + } + fclose($fp); + } + } + +} // End HttpQPlayer Class + + +?> -- cgit