cvs: pear /XMMS php_xmms.h xmms.c xmms.php

From: Date: Sun, 12 Aug 2001 07:07:57 +0000
Subject: cvs: pear /XMMS php_xmms.h xmms.c xmms.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-476@lists.php.net to get a copy of this message
rasmus Sun Aug 12 03:07:57 2001 EDT Modified files: /pear/XMMS php_xmms.h xmms.c xmms.php Log: - Add xmms_playlist_length() - Shut down xmms if it is running when server exits. If I don't do this xmms will hold onto port 80 and a new httpd will not be able to bind to it - Spruce up web interface a bit - need an html wizard to make a nice one (by the way, you can see this in action at http://lerdorf.com/xmms.php) Index: pear/XMMS/php_xmms.h diff -u pear/XMMS/php_xmms.h:1.4 pear/XMMS/php_xmms.h:1.5 --- pear/XMMS/php_xmms.h:1.4 Sat Aug 11 02:57:32 2001 +++ pear/XMMS/php_xmms.h Sun Aug 12 03:07:57 2001 @@ -39,6 +39,7 @@ PHP_MINFO_FUNCTION(xmms); PHP_FUNCTION(xmms_start); +PHP_FUNCTION(xmms_playlist_length); PHP_FUNCTION(xmms_playlist_pos); PHP_FUNCTION(xmms_playlist); PHP_FUNCTION(xmms_play); Index: pear/XMMS/xmms.c diff -u pear/XMMS/xmms.c:1.6 pear/XMMS/xmms.c:1.7 --- pear/XMMS/xmms.c:1.6 Sun Aug 12 01:50:28 2001 +++ pear/XMMS/xmms.c Sun Aug 12 03:07:57 2001 @@ -33,6 +33,7 @@ */ function_entry xmms_functions[] = { PHP_FE(xmms_start, NULL) + PHP_FE(xmms_playlist_length, NULL) PHP_FE(xmms_playlist_pos, NULL) PHP_FE(xmms_playlist, NULL) PHP_FE(xmms_play, NULL) @@ -106,6 +107,9 @@ */ PHP_MSHUTDOWN_FUNCTION(xmms) { + if(xmms_remote_is_running(XG(session))) { + xmms_remote_quit(XG(session)); + } UNREGISTER_INI_ENTRIES(); return SUCCESS; } @@ -181,6 +185,17 @@ } else { RETURN_FALSE; } +} +/* }}} */ + +/* {{{ proto void xmms_playlist_length(void) + Get the number of songs in the playlist */ +PHP_FUNCTION(xmms_playlist_length) +{ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + + RETURN_LONG(xmms_remote_get_playlist_length(XG(session))); } /* }}} */ Index: pear/XMMS/xmms.php diff -u pear/XMMS/xmms.php:1.1 pear/XMMS/xmms.php:1.2 --- pear/XMMS/xmms.php:1.1 Sat Aug 11 13:44:03 2001 +++ pear/XMMS/xmms.php Sun Aug 12 03:07:57 2001 @@ -1,5 +1,13 @@ +<html><head><title>PHP-XMMS Controller</title></head> +<body> <? xmms_start(); +if(isset($url)) { + xmms_url($url); + $len = xmms_playlist_length(); + xmms_play($len-1); + sleep(1); +} switch($action) { case 'play': xmms_play(); @@ -22,19 +30,21 @@ } if($action) usleep(200); ?> +<table><tr><td bgcolor=#000000> <form action="<?echo $PHP_SELF?>" method="POST"> -<table> +<table cellspacing=3 cellpadding=3> <? $song = xmms_current(); $channels = array(1=>'Mono',2=>'Stereo'); ?> -<tr><td colspan=4><?echo $song['pos'].': '.$song['title']?></td></tr> -<?$progress = (int)(($song['timepos']/$song['time'])*100); +<tr bgcolor=#002244><td colspan=4><font color=#60afbf><?echo $song['pos'].': '.$song['title']?></font></td></tr> +<? if($song['time'] < 0.1) $progress = 'Playing from <a href="'.$song['file'].'">URL</a>'; + else $progress = (int)(($song['timepos']/$song['time'])*100) .'%'; $min = (int)($song['timepos']/60); $sec = sprintf('%02d',$song['timepos']%60); ?> -<tr><td colspan=4><?echo "$min:$sec (".$progress.'%)'?></td></tr> -<tr><td colspan=4><?echo ($song['rate']/1000).'kbps '.($song['freq']/1000).'kHz '.$channels[$song['nch']]?></td></tr> +<tr><td colspan=4><font color=#99bbcc><?echo "$min:$sec (".$progress.')'?></font></td></tr> +<tr><td colspan=4><font color=#bb99cc><?echo ($song['rate']/1000).'kbps '.($song['freq']/1000).'kHz '.$channels[$song['nch']]?></font></td></tr> <tr><td><input type=submit name=action value=prev></td> <?$status = xmms_status(); if($status=="Playing" || $status=="Paused") {?> @@ -49,5 +59,7 @@ <? } ?> <td><input type=submit name=action value=next></td> </tr> +<tr><td colspan=4><font color=#99ccbb>url: </font><input type=text name=url></td></tr> </form> -</table> +</table></td></tr></table> +</body></html>

« previous php.pear.cvs (#476) next »