cvs: pear /XMMS README xmms.c
| From: | Rasmus Lerdorf | Date: | Tue, 14 Aug 2001 22:17:26 +0000 |
| Subject: | cvs: pear /XMMS README xmms.c | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-521@lists.php.net to get a copy of this message | ||
rasmus Tue Aug 14 18:17:26 2001 EDT
Modified files:
/pear/XMMS README xmms.c
Log:
Bit more work on the OO interface - need to add PEAR-style docs to
these classes now and do the final pearification. Hopefully this
can be a model for future PEAR C classes.
Index: pear/XMMS/README
diff -u pear/XMMS/README:1.3 pear/XMMS/README:1.4
--- pear/XMMS/README:1.3 Sat Aug 11 13:46:37 2001
+++ pear/XMMS/README Tue Aug 14 18:17:23 2001
@@ -22,6 +22,30 @@
as your web server user id yourself and xmms_start() will detect
that it is already running and talk to the running instance.
+Both a procedural and an OO API is provided.
+
+eg.
+
+Procedural:
+-----------
+<?php
+ xmms_start();
+ xmms_play();
+ $info = xmms_current();
+ echo $info['title'];
+ echo $info['file'];
+?>
+
+OO:
+---
+<?php
+ $x = new xmms(true);
+ $x->play();
+ $x->current();
+ echo $x->title;
+ echo $x->file;
+?>
+
Known Bugs
----------
Index: pear/XMMS/xmms.c
diff -u pear/XMMS/xmms.c:1.14 pear/XMMS/xmms.c:1.15
--- pear/XMMS/xmms.c:1.14 Tue Aug 14 03:50:00 2001
+++ pear/XMMS/xmms.c Tue Aug 14 18:17:23 2001
@@ -238,7 +238,8 @@
WRONG_PARAM_COUNT;
}
- RETURN_BOOL(xmms_remote_is_running(XG(session))?1:0);
+ RETVAL_BOOL(xmms_remote_is_running(XG(session))?1:0);
+ if(this_ptr) add_property_bool(this_ptr, "running", Z_BVAL_P(return_value));
}
/* }}} */
@@ -255,7 +256,8 @@
RETURN_FALSE;
}
- RETURN_LONG(xmms_remote_get_playlist_length(XG(session)));
+ RETVAL_LONG(xmms_remote_get_playlist_length(XG(session)));
+ if(this_ptr) add_property_long(this_ptr, "playlist_length", Z_LVAL_P(return_value));
}
/* }}} */
@@ -272,7 +274,8 @@
RETURN_FALSE;
}
- RETURN_LONG(xmms_remote_get_playlist_pos(XG(session)));
+ RETVAL_LONG(xmms_remote_get_playlist_pos(XG(session)));
+ if(this_ptr) add_property_long(this_ptr, "playlist_pos", Z_LVAL_P(return_value));
}
/* }}} */
@@ -412,6 +415,7 @@
}
xmms_remote_quit(XG(session));
+ if(this_ptr) add_property_bool(this_ptr, "is_running", 0);
}
/* }}} */
@@ -428,7 +432,8 @@
RETURN_FALSE;
}
- RETURN_LONG(xmms_remote_get_version(XG(session)));
+ RETVAL_LONG(xmms_remote_get_version(XG(session)));
+ if(this_ptr) add_property_long(this_ptr, "version", Z_LVAL_P(return_value));
}
/* }}} */
@@ -471,6 +476,7 @@
PHP_FUNCTION(xmms_status)
{
int playing, paused;
+ pval **status;
if(ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
@@ -485,14 +491,16 @@
paused = xmms_remote_is_paused(XG(session));
if(paused) {
- RETURN_STRINGL("Paused",6,1);
+ RETVAL_STRINGL("Paused",6,1);
} else {
if(playing) {
- RETURN_STRINGL("Playing",7,1);
+ RETVAL_STRINGL("Playing",7,1);
} else {
- RETURN_STRINGL("Stopped",7,1);
+ RETVAL_STRINGL("Stopped",7,1);
}
}
+ /* If we were called as a class method, update the status property */
+ if(this_ptr) add_property_stringl(this_ptr, "status", Z_STRVAL_P(return_value),
Z_STRLEN_P(return_value), 1);
}
/* }}} */
@@ -509,7 +517,8 @@
RETURN_FALSE;
}
- RETURN_BOOL(xmms_remote_is_repeat(XG(session)));
+ RETVAL_BOOL(xmms_remote_is_repeat(XG(session)));
+ if(this_ptr) add_property_bool(this_ptr, "repeat", Z_BVAL_P(return_value));
}
/* }}} */
@@ -558,7 +567,8 @@
RETURN_FALSE;
}
- RETURN_BOOL(xmms_remote_is_shuffle(XG(session)));
+ RETVAL_BOOL(xmms_remote_is_shuffle(XG(session)));
+ if(this_ptr) add_property_bool(this_ptr, "shuffle", Z_BVAL_P(return_value));
}
/* }}} */
@@ -694,6 +704,19 @@
add_assoc_long(return_value, "rate", rate);
add_assoc_long(return_value, "freq", freq);
add_assoc_long(return_value, "nch", nch);
+ if(this_ptr) {
+ add_property_long(this_ptr, "pos", pos);
+ if(fn) add_property_string(this_ptr, "file", fn, 1);
+ if(title) add_property_string(this_ptr, "title", title, 1);
+ if(status) add_property_string(this_ptr, "status", status, 1);
+ add_property_double(this_ptr, "time", (double)(time/1000.0));
+ add_property_double(this_ptr, "timepos", (double)(timepos/1000.0));
+ add_property_bool(this_ptr, "repeat", repeat);
+ add_property_bool(this_ptr, "shuffle", shuffle);
+ add_property_long(this_ptr, "rate", rate);
+ add_property_long(this_ptr, "freq", freq);
+ add_property_long(this_ptr, "nch", nch);
+ }
}
/* }}} */
@@ -783,14 +806,14 @@
}
/* }}} */
-/* {{{ proto void xmms_main_win([bool setting])
+/* {{{ proto void xmms_main_win(bool setting)
Hide/Unhide main xmms window */
PHP_FUNCTION(xmms_main_win)
{
int argc = ZEND_NUM_ARGS();
zend_bool setting;
- if (zend_parse_parameters(argc TSRMLS_CC, "|b", &setting) == FAILURE)
+ if (zend_parse_parameters(argc TSRMLS_CC, "b", &setting) == FAILURE)
return;
if(!xmms_remote_is_running(XG(session))) {
@@ -802,14 +825,14 @@
}
/* }}} */
-/* {{{ proto void xmms_pl_win([bool setting])
+/* {{{ proto void xmms_pl_win(bool setting)
Hide/Unhide playlist xmms window */
PHP_FUNCTION(xmms_pl_win)
{
int argc = ZEND_NUM_ARGS();
zend_bool setting;
- if (zend_parse_parameters(argc TSRMLS_CC, "|b", &setting) == FAILURE)
+ if (zend_parse_parameters(argc TSRMLS_CC, "b", &setting) == FAILURE)
return;
if(!xmms_remote_is_running(XG(session))) {
@@ -821,14 +844,14 @@
}
/* }}} */
-/* {{{ proto void xmms_eq_win([bool setting])
+/* {{{ proto void xmms_eq_win(bool setting)
Hide/Unhide equalizer xmms window */
PHP_FUNCTION(xmms_eq_win)
{
int argc = ZEND_NUM_ARGS();
zend_bool setting;
- if (zend_parse_parameters(argc, "|b", &setting) == FAILURE)
+ if (zend_parse_parameters(argc, "b", &setting) == FAILURE)
return;
if(!xmms_remote_is_running(XG(session))) {
@@ -858,15 +881,14 @@
if(xmms_remote_is_running(XG(session))) {
add_property_long(this_ptr, "version", xmms_remote_get_version(XG(session)));
- add_property_bool(this_ptr, "is_running", 1);
- add_property_bool(this_ptr, "is_repeat", xmms_remote_is_repeat(XG(session)));
- add_property_bool(this_ptr, "is_shuffle", xmms_remote_is_shuffle(XG(session)));
- add_property_bool(this_ptr, "shuffle", 1);
+ add_property_bool(this_ptr, "running", 1);
+ add_property_bool(this_ptr, "repeat", xmms_remote_is_repeat(XG(session)));
+ add_property_bool(this_ptr, "shuffle", xmms_remote_is_shuffle(XG(session)));
} else {
add_property_long(this_ptr, "version", 0);
- add_property_bool(this_ptr, "is_running", 0);
- add_property_bool(this_ptr, "is_repeat", 0);
- add_property_bool(this_ptr, "is_shuffle", 0);
+ add_property_bool(this_ptr, "running", 0);
+ add_property_bool(this_ptr, "repeat", 0);
+ add_property_bool(this_ptr, "shuffle", 0);
}
}
/* }}} */