cvs: pear /XMMS .cvsignore CREDITS EXPERIMENTAL Makefile.in README config.m4 gtkxmms php_xmms.h xmms.c xmms.glade
| From: | Rasmus Lerdorf | Date: | Thu, 09 Aug 2001 23:55:08 +0000 |
| Subject: | cvs: pear /XMMS .cvsignore CREDITS EXPERIMENTAL Makefile.in README config.m4 gtkxmms php_xmms.h xmms.c xmms.glade | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-450@lists.php.net to get a copy of this message | ||
rasmus Thu Aug 9 19:55:08 2001 EDT
Added files:
/pear/XMMS .cvsignore CREDITS EXPERIMENTAL Makefile.in README
config.m4 gtkxmms php_xmms.h xmms.c xmms.glade
Log:
Add XMMS extension
Index: pear/XMMS/.cvsignore +++ pear/XMMS/.cvsignore deps Makefile *.lo *.la libs libs.mk Index: pear/XMMS/Makefile.in +++ pear/XMMS/Makefile.in # $Id: Makefile.in,v 1.1 2001/08/09 23:55:08 rasmus Exp $ LTLIBRARY_NAME = libxmms.la LTLIBRARY_SOURCES = xmms.c LTLIBRARY_SHARED_NAME = xmms.la LTLIBRARY_SHARED_LIBADD = $(XMMS_SHARED_LIBADD) include $(top_srcdir)/build/dynlib.mk Index: pear/XMMS/config.m4 +++ pear/XMMS/config.m4 dnl $Id: config.m4,v 1.1 2001/08/09 23:55:08 rasmus Exp $ dnl config.m4 for extension xmms PHP_ARG_WITH(xmms, for xmms support, [ --with-xmms[=DIR] Include xmms support]) if test "$PHP_XMMS" != "no"; then SEARCH_PATH="/usr/local /usr" # you might want to change this SEARCH_FOR="/include/xmms/xmmsctrl.h" # you most likely want to change this if test -r $PHP_XMMS/; then # path given as parameter XMMS_DIR=$PHP_XMMS else # search default path list AC_MSG_CHECKING(for xmms files in default path) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then XMMS_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$XMMS_DIR"; then AC_MSG_RESULT(not found) AC_MSG_ERROR(Please specify path to your xmms distribution files) fi PHP_ADD_INCLUDE(/usr/include/glib-1.2) PHP_ADD_INCLUDE(/usr/lib/glib/include) dnl # --with-xmms -> chech for lib and symbol presence LIBNAME=xmms LIBSYMBOL=xmms_remote_get_version old_LIBS=$LIBS LIBS="$LIBS -L$XMMS_DIR/lib -lm -ldl" AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_XMMSLIB,1,[ ])], [AC_MSG_ERROR(wrong xmms lib version or lib not found)]) LIBS=$old_LIBS PHP_SUBST(XMMS_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $XMMS_DIR/lib, XMMS_SHARED_LIBADD) PHP_EXTENSION(xmms, $ext_shared) fi Index: pear/XMMS/php_xmms.h +++ pear/XMMS/php_xmms.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ #ifndef PHP_XMMS_H #define PHP_XMMS_H extern zend_module_entry xmms_module_entry; #define phpext_xmms_ptr &xmms_module_entry #ifdef PHP_WIN32 #define PHP_XMMS_API __declspec(dllexport) #else #define PHP_XMMS_API #endif #ifdef ZTS #include "TSRM.h" #endif #include <xmms/xmmsctrl.h> PHP_MINIT_FUNCTION(xmms); PHP_MSHUTDOWN_FUNCTION(xmms); PHP_MINFO_FUNCTION(xmms); PHP_FUNCTION(xmms_start); PHP_FUNCTION(xmms_playlist_pos); PHP_FUNCTION(xmms_playlist); PHP_FUNCTION(xmms_play); PHP_FUNCTION(xmms_stop); PHP_FUNCTION(xmms_pause); PHP_FUNCTION(xmms_quit); PHP_FUNCTION(xmms_version); PHP_FUNCTION(xmms_next); PHP_FUNCTION(xmms_prev); PHP_FUNCTION(xmms_status); PHP_FUNCTION(xmms_is_repeat); PHP_FUNCTION(xmms_repeat); PHP_FUNCTION(xmms_is_shuffle); PHP_FUNCTION(xmms_shuffle); PHP_FUNCTION(xmms_add); PHP_FUNCTION(xmms_delete); PHP_FUNCTION(xmms_clear); PHP_FUNCTION(xmms_current); PHP_FUNCTION(xmms_volume); PHP_FUNCTION(xmms_url); PHP_FUNCTION(xmms_skin); PHP_FUNCTION(xmms_time); ZEND_BEGIN_MODULE_GLOBALS(xmms) int session; ZEND_END_MODULE_GLOBALS(xmms) /* In every function that needs to use variables in php_xmms_globals, call TSRM_FETCH(); after declaring other variables used by that function, and always refer to them as XMMS_G(variable). You are encouraged to rename these macros something shorter, see examples in any other php module directory. */ #ifdef ZTS #define XG(v) TSRMG(xmms_globals_id, zend_xmms_globals *, v) #else #define XG(v) (xmms_globals.v) #endif #endif /* PHP_XMMS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: */ Index: pear/XMMS/xmms.c +++ pear/XMMS/xmms.c /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_xmms.h" /* If you declare any globals in php_xmms.h uncomment this: ZEND_DECLARE_MODULE_GLOBALS(xmms) */ /* {{{ xmms_functions[] * * Every user visible function must have an entry in xmms_functions[]. */ function_entry xmms_functions[] = { PHP_FE(xmms_start, NULL) PHP_FE(xmms_playlist_pos, NULL) PHP_FE(xmms_playlist, NULL) PHP_FE(xmms_play, NULL) PHP_FE(xmms_stop, NULL) PHP_FE(xmms_pause, NULL) PHP_FE(xmms_quit, NULL) PHP_FE(xmms_version, NULL) PHP_FE(xmms_next, NULL) PHP_FE(xmms_prev, NULL) PHP_FE(xmms_status, NULL) PHP_FE(xmms_is_repeat, NULL) PHP_FE(xmms_repeat, NULL) PHP_FE(xmms_is_shuffle, NULL) PHP_FE(xmms_shuffle, NULL) PHP_FE(xmms_add, NULL) PHP_FE(xmms_delete, NULL) PHP_FE(xmms_clear, NULL) PHP_FE(xmms_current, NULL) PHP_FE(xmms_volume, NULL) PHP_FE(xmms_url, NULL) PHP_FE(xmms_skin, NULL) PHP_FE(xmms_time, NULL) {NULL, NULL, NULL} /* Must be the last line in xmms_functions[] */ }; /* }}} */ /* {{{ xmms_module_entry */ zend_module_entry xmms_module_entry = { "xmms", xmms_functions, PHP_MINIT(xmms), PHP_MSHUTDOWN(xmms), NULL, NULL, PHP_MINFO(xmms), STANDARD_MODULE_PROPERTIES }; /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(xmms) #ifdef COMPILE_DL_XMMS ZEND_GET_MODULE(xmms) #endif /* {{{ php_xmms_init_globals */ static void php_xmms_init_globals(zend_xmms_globals *xmms_globals) { xmms_globals->session = 0; } /* }}} */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("xmms.session", "0", PHP_INI_ALL, OnUpdateInt, session, zend_xmms_globals, xmms_globals) PHP_INI_END() /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(xmms) { ZEND_INIT_MODULE_GLOBALS(xmms, php_xmms_init_globals, NULL); REGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(xmms) { UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(xmms) { char buf[16]; int running, pos; php_info_print_table_start(); php_info_print_table_header(2, "xmms support", "enabled"); running = xmms_remote_is_running(XG(session)); if(running) { if(xmms_remote_is_paused(XG(session))) { php_info_print_table_row(2, "XMMS Status", "Paused"); } else { if(xmms_remote_is_playing(XG(session))) { php_info_print_table_row(2, "XMMS Status", "Playing"); } else { php_info_print_table_row(2, "XMMS Status", "Stopped"); } } sprintf(buf, "%d", xmms_remote_get_version(XG(session))); php_info_print_table_row(2, "XMMS Version", buf); pos = xmms_remote_get_playlist_pos(XG(session)); sprintf(buf, "%d", pos); php_info_print_table_row(2, "Current Playlist Entry #", buf); php_info_print_table_row(2, "Current Song", xmms_remote_get_playlist_title(XG(session), pos)); php_info_print_table_row(2, "Current Filename", xmms_remote_get_playlist_file(XG(session), pos)); sprintf(buf, "%.3f", (double)(xmms_remote_get_playlist_time(XG(session), pos)/1000.0)); php_info_print_table_row(2, "Current Song Length", buf); sprintf(buf, "%.3f", (double)(xmms_remote_get_output_time(XG(session))/1000.0)); php_info_print_table_row(2, "Current Song Position", buf); } else { php_info_print_table_row(2, "XMMS Status", "Not Running"); } php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } /* }}} */ /* {{{ proto int xmms_start(void) Start up XMMS if it is not already running */ PHP_FUNCTION(xmms_start) { pid_t pid; char *av[] = { "xmms",NULL }; if(!xmms_remote_is_running(XG(session))) { /* Ok, this is pretty weird, but hey, why not? */ pid = fork(); if(pid > 0) { daemon(1,0); if(execve("/usr/bin/xmms",av,environ)==-1) { php_error(E_WARNING, "Unable to exec XMMS"); exit(-1); } } else if(pid==0) sleep(1); else if(pid==-1) { php_error(E_WARNING, "Unable to fork XMMS"); RETURN_FALSE; } } if(xmms_remote_is_running(XG(session))) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int xmms_playlist_pos(void) Get current playlist position */ PHP_FUNCTION(xmms_playlist_pos) { RETURN_LONG(xmms_remote_get_playlist_pos(XG(session))); } /* }}} */ /* {{{ proto array xmms_playlist([int pos]) Get full playlist */ PHP_FUNCTION(xmms_playlist) { zval **pos_arg; int pos, len, i; int argc = ZEND_NUM_ARGS(); pval *tmp; if (argc > 1 || (argc && zend_get_parameters_ex(argc, &pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); /* Fall-through. */ case 0: break; } array_init(return_value); if(!argc) { len = xmms_remote_get_playlist_length(XG(session)); for(i=0; i<len; i++) { MAKE_STD_ZVAL(tmp); array_init(tmp); add_assoc_string(tmp, "title", xmms_remote_get_playlist_title(XG(session),i), 1); add_assoc_string(tmp, "file", xmms_remote_get_playlist_file(XG(session),i), 1); add_assoc_double(tmp, "time", xmms_remote_get_playlist_time(XG(session),i)/1000.0); zend_hash_index_update(return_value->value.ht, i, &tmp, sizeof(tmp), NULL); } } else { array_init(return_value); add_assoc_string(return_value, "title", xmms_remote_get_playlist_title(XG(session),pos), 1); add_assoc_string(return_value, "file", xmms_remote_get_playlist_file(XG(session),pos), 1); add_assoc_double(return_value, "time", xmms_remote_get_playlist_time(XG(session),pos)/1000.0); } } /* }}} */ /* {{{ proto void xmms_play([int pos]) */ PHP_FUNCTION(xmms_play) { zval **pos_arg; int pos; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); xmms_remote_set_playlist_pos(XG(session), pos); /* Fall-through. */ case 0: xmms_remote_play(XG(session)); break; } } /* }}} */ /* {{{ proto void xmms_stop() Stop playing current song */ PHP_FUNCTION(xmms_stop) { xmms_remote_stop(XG(session)); } /* }}} */ /* {{{ proto xmms_pause(void) Pause current song (toggle) */ PHP_FUNCTION(xmms_pause) { xmms_remote_pause(XG(session)); } /* }}} */ /* {{{ proto void xmms_quit(void) Force XMMS to terminate */ PHP_FUNCTION(xmms_quit) { xmms_remote_quit(XG(session)); } /* }}} */ /* {{{ proto int xmms_version(void) Get the XMMS version */ PHP_FUNCTION(xmms_version) { int version; version = xmms_remote_get_version(XG(session)); RETURN_LONG(version); } /* }}} */ /* {{{ proto void xmms_next(void) Go to next song in playlist */ PHP_FUNCTION(xmms_next) { xmms_remote_playlist_next(XG(session)); } /* }}} */ /* {{{ proto void xmms_prev(void) Go to previous song in playlist */ PHP_FUNCTION(xmms_prev) { xmms_remote_playlist_prev(XG(session)); } /* }}} */ /* {{{ proto string xmms_status(void) Returns current XMMS status */ PHP_FUNCTION(xmms_status) { int playing, paused; playing = xmms_remote_is_playing(XG(session)); paused = xmms_remote_is_paused(XG(session)); if(paused) { RETURN_STRINGL("Paused",6,1); } else { if(playing) { RETURN_STRINGL("Playing",7,1); } else { RETURN_STRINGL("Stopped",7,1); } } } /* }}} */ /* {{{ proto bool xmms_is_repeat(void) Get repeat setting */ PHP_FUNCTION(xmms_is_repeat) { RETURN_BOOL(xmms_remote_is_repeat(XG(session))); } /* }}} */ /* {{{ proto int xmms_repeat([int setting]) Toggle/Set repeat setting */ PHP_FUNCTION(xmms_repeat) { zval **setting_arg; int setting; gboolean current; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &setting_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(setting_arg); setting = Z_LVAL_PP(setting_arg); if(setting) setting=TRUE; else setting=FALSE; /* Fall-through. */ case 0: break; } if(argc) { current = xmms_remote_is_repeat(XG(session)); if(current) current=TRUE; else current=FALSE; if(current != setting) { xmms_remote_toggle_repeat(XG(session)); } } else { setting = !xmms_remote_is_repeat(XG(session)); xmms_remote_toggle_repeat(XG(session)); } RETURN_BOOL(setting); } /* }}} */ /* {{{ proto bool xmms_is_shuffle(void) Get shuffle setting */ PHP_FUNCTION(xmms_is_shuffle) { RETURN_BOOL(xmms_remote_is_shuffle(XG(session))); } /* }}} */ /* {{{ proto int xmms_shuffle([int setting]) Toggle/Set shuffle setting*/ PHP_FUNCTION(xmms_shuffle) { zval **setting_arg; int setting; gboolean current; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &setting_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(setting_arg); setting = Z_LVAL_PP(setting_arg); if(setting) setting=TRUE; else setting=FALSE; /* Fall-through. */ case 0: break; } if(argc) { current = xmms_remote_is_shuffle(XG(session)); if(current) current=TRUE; else current=FALSE; if(current != setting) { xmms_remote_toggle_shuffle(XG(session)); } } else { setting = !xmms_remote_is_shuffle(XG(session)); xmms_remote_toggle_shuffle(XG(session)); } RETURN_BOOL(setting); } /* }}} */ /* {{{ proto xmms_add(mixed songs) Add entries to playlist */ PHP_FUNCTION(xmms_add) { zval **songs_arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &songs_arg) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } /* Write your own code here to handle argument songs. */ php_error(E_WARNING, "xmms_add: not yet implemented"); } /* }}} */ /* {{{ proto xmms_delete(int pos) Delete entry from playlist */ PHP_FUNCTION(xmms_delete) { zval **pos_arg; int pos; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pos_arg) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); php_error(E_WARNING, "xmms_delete: not yet implemented"); } /* }}} */ /* {{{ proto xmms_clear() Clear playlist */ PHP_FUNCTION(xmms_clear) { php_error(E_WARNING, "xmms_clear: not yet implemented"); } /* }}} */ /* {{{ proto array xmms_current(void) Get current song info */ PHP_FUNCTION(xmms_current) { long pos, time, timepos; char *fn, *title; int rate, freq, nch; int playing, paused, repeat, shuffle; char status[10]; playing = xmms_remote_is_playing(XG(session)); paused = xmms_remote_is_paused(XG(session)); timepos = xmms_remote_get_output_time(XG(session)); pos = xmms_remote_get_playlist_pos(XG(session)); fn = xmms_remote_get_playlist_file(XG(session), pos); title = xmms_remote_get_playlist_title(XG(session), pos); time = xmms_remote_get_playlist_time(XG(session), pos); repeat = xmms_remote_is_repeat(XG(session)); shuffle = xmms_remote_is_shuffle(XG(session)); if(paused) strcpy(status,"Paused"); else { if(playing) strcpy(status,"Playing"); else strcpy(status,"Stopped"); } xmms_remote_get_info(XG(session), &rate, &freq, &nch); array_init(return_value); add_assoc_long(return_value, "pos", pos); add_assoc_string(return_value, "file", fn, 1); add_assoc_string(return_value, "title", title, 1); add_assoc_double(return_value, "time", (double)(time/1000.0)); add_assoc_double(return_value, "timepos", (double)(timepos/1000.0)); add_assoc_string(return_value, "status", status, 1); add_assoc_bool(return_value, "repeat", repeat); add_assoc_bool(return_value, "shuffle", shuffle); add_assoc_long(return_value, "rate", rate); add_assoc_long(return_value, "freq", freq); add_assoc_long(return_value, "nch", nch); } /* }}} */ /* {{{ proto xmms_volume([int level [, int right_level]]) */ PHP_FUNCTION(xmms_volume) { zval **level_arg, **right_level_arg; int level; int right_level; int argc = ZEND_NUM_ARGS(); if (argc > 2 || (argc && zend_get_parameters_ex(argc, &level_arg, &right_level_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 2: convert_to_long_ex(right_level_arg); right_level = Z_LVAL_PP(right_level_arg); /* Fall-through. */ case 1: convert_to_long_ex(level_arg); level = Z_LVAL_PP(level_arg); /* Fall-through. */ case 0: break; } php_error(E_WARNING, "xmms_volume: not yet implemented"); } /* }}} */ /* {{{ proto void xmms_url(string url) Play from url */ PHP_FUNCTION(xmms_url) { zval **url; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &url) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } convert_to_string_ex(url); /* this add_url call doesn't seem to work - not sure why yet */ xmms_remote_playlist_add_url_string(XG(session),Z_STRVAL_PP(url)); } /* }}} */ /* {{{ proto xmms_skin([string skin_file]) */ PHP_FUNCTION(xmms_skin) { zval **skin_file_arg; char *skin_file = NULL; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &skin_file_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_string_ex(skin_file_arg); skin_file = Z_STRVAL_PP(skin_file_arg); /* Fall-through. */ case 0: break; } php_error(E_WARNING, "xmms_skin: not yet implemented"); } /* }}} */ /* {{{ proto float xmms_time([float time_pos]) Get/Set output time position */ PHP_FUNCTION(xmms_time) { zval **time_pos_arg; double time_pos; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &time_pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_double_ex(time_pos_arg); time_pos = Z_DVAL_PP(time_pos_arg); xmms_remote_jump_to_time(XG(session), (int)(time_pos*1000)); RETVAL_DOUBLE(time_pos); /* Fall-through. */ case 0: RETVAL_DOUBLE((double)(xmms_remote_get_output_time(XG(session))/1000.0)); break; } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: sw=4 ts=4 tw=78 fdm=marker * vim<600: sw=4 ts=4 tw=78 */ Index: pear/XMMS/xmms.glade +++ pear/XMMS/xmms.glade <?xml version="1.0"?> <GTK-Interface> <project> <name>Xmms</name> <program_name>xmms</program_name> <directory></directory> <source_directory>src</source_directory> <pixmaps_directory>pixmaps</pixmaps_directory> <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> <output_main_file>False</output_main_file> <output_support_files>False</output_support_files> <output_build_files>False</output_build_files> </project> <widget> <class>GtkWindow</class> <name>xmms</name> <signal> <name>destroy</name> <handler>destroy</handler> <last_modification_time>Thu, 09 Aug 2001 15:21:09 GMT</last_modification_time> </signal> <signal> <name>delete_event</name> <handler>delete_event</handler> <last_modification_time>Thu, 09 Aug 2001 15:21:47 GMT</last_modification_time> </signal> <signal> <name>destroy_event</name> <handler>destroy</handler> <last_modification_time>Thu, 09 Aug 2001 15:22:09 GMT</last_modification_time> </signal> <title>PHP-XMMS</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> <modal>False</modal> <allow_shrink>False</allow_shrink> <allow_grow>False</allow_grow> <auto_shrink>False</auto_shrink> <widget> <class>GtkAlignment</class> <name>alignment1</name> <xalign>0.5</xalign> <yalign>0.5</yalign> <xscale>1</xscale> <yscale>1</yscale> <widget> <class>GtkTable</class> <name>table1</name> <rows>3</rows> <columns>4</columns> <homogeneous>False</homogeneous> <row_spacing>0</row_spacing> <column_spacing>0</column_spacing> <widget> <class>GtkButton</class> <name>prev</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_prev_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 17:19:37 GMT</last_modification_time> </signal> <label>Previous</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>0</left_attach> <right_attach>1</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>next</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_next_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 05:14:19 GMT</last_modification_time> </signal> <label>Next</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>3</left_attach> <right_attach>4</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>play</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_play_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 05:41:35 GMT</last_modification_time> </signal> <label>Play</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>pause</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>xmms_pause</handler> <last_modification_time>Thu, 09 Aug 2001 05:38:57 GMT</last_modification_time> </signal> <label>Pause</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>2</left_attach> <right_attach>3</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkToggleButton</class> <name>shuffle</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>toggled</name> <handler>on_shuffle_toggled</handler> <last_modification_time>Thu, 09 Aug 2001 05:51:09 GMT</last_modification_time> </signal> <label>Shuffle</label> <relief>GTK_RELIEF_HALF</relief> <active>False</active> <child> <left_attach>2</left_attach> <right_attach>3</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkToggleButton</class> <name>repeat</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>toggled</name> <handler>on_repeat_toggled</handler> <last_modification_time>Thu, 09 Aug 2001 05:52:25 GMT</last_modification_time> </signal> <label>Repeat</label> <relief>GTK_RELIEF_HALF</relief> <active>False</active> <child> <left_attach>3</left_attach> <right_attach>4</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkProgressBar</class> <name>time</name> <value>0</value> <lower>0</lower> <upper>100</upper> <bar_style>GTK_PROGRESS_CONTINUOUS</bar_style> <orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation> <activity_mode>False</activity_mode> <show_text>True</show_text> <format>%vs (%p%%)</format> <text_xalign>0.5</text_xalign> <text_yalign>0.5</text_yalign> <child> <left_attach>0</left_attach> <right_attach>2</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkLabel</class> <name>status</name> <label></label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0</xalign> <yalign>0.5</yalign> <xpad>2</xpad> <ypad>2</ypad> <child> <left_attach>0</left_attach> <right_attach>4</right_attach> <top_attach>0</top_attach> <bottom_attach>1</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> </widget> </widget> </widget> </GTK-Interface>
Index: pear/XMMS/.cvsignore +++ pear/XMMS/.cvsignore deps Makefile *.lo *.la libs libs.mk Index: pear/XMMS/Makefile.in +++ pear/XMMS/Makefile.in # $Id: Makefile.in,v 1.1 2001/08/09 23:55:08 rasmus Exp $ LTLIBRARY_NAME = libxmms.la LTLIBRARY_SOURCES = xmms.c LTLIBRARY_SHARED_NAME = xmms.la LTLIBRARY_SHARED_LIBADD = $(XMMS_SHARED_LIBADD) include $(top_srcdir)/build/dynlib.mk Index: pear/XMMS/config.m4 +++ pear/XMMS/config.m4 dnl $Id: config.m4,v 1.1 2001/08/09 23:55:08 rasmus Exp $ dnl config.m4 for extension xmms PHP_ARG_WITH(xmms, for xmms support, [ --with-xmms[=DIR] Include xmms support]) if test "$PHP_XMMS" != "no"; then SEARCH_PATH="/usr/local /usr" # you might want to change this SEARCH_FOR="/include/xmms/xmmsctrl.h" # you most likely want to change this if test -r $PHP_XMMS/; then # path given as parameter XMMS_DIR=$PHP_XMMS else # search default path list AC_MSG_CHECKING(for xmms files in default path) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then XMMS_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$XMMS_DIR"; then AC_MSG_RESULT(not found) AC_MSG_ERROR(Please specify path to your xmms distribution files) fi PHP_ADD_INCLUDE(/usr/include/glib-1.2) PHP_ADD_INCLUDE(/usr/lib/glib/include) dnl # --with-xmms -> chech for lib and symbol presence LIBNAME=xmms LIBSYMBOL=xmms_remote_get_version old_LIBS=$LIBS LIBS="$LIBS -L$XMMS_DIR/lib -lm -ldl" AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_XMMSLIB,1,[ ])], [AC_MSG_ERROR(wrong xmms lib version or lib not found)]) LIBS=$old_LIBS PHP_SUBST(XMMS_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $XMMS_DIR/lib, XMMS_SHARED_LIBADD) PHP_EXTENSION(xmms, $ext_shared) fi Index: pear/XMMS/php_xmms.h +++ pear/XMMS/php_xmms.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ #ifndef PHP_XMMS_H #define PHP_XMMS_H extern zend_module_entry xmms_module_entry; #define phpext_xmms_ptr &xmms_module_entry #ifdef PHP_WIN32 #define PHP_XMMS_API __declspec(dllexport) #else #define PHP_XMMS_API #endif #ifdef ZTS #include "TSRM.h" #endif #include <xmms/xmmsctrl.h> PHP_MINIT_FUNCTION(xmms); PHP_MSHUTDOWN_FUNCTION(xmms); PHP_MINFO_FUNCTION(xmms); PHP_FUNCTION(xmms_start); PHP_FUNCTION(xmms_playlist_pos); PHP_FUNCTION(xmms_playlist); PHP_FUNCTION(xmms_play); PHP_FUNCTION(xmms_stop); PHP_FUNCTION(xmms_pause); PHP_FUNCTION(xmms_quit); PHP_FUNCTION(xmms_version); PHP_FUNCTION(xmms_next); PHP_FUNCTION(xmms_prev); PHP_FUNCTION(xmms_status); PHP_FUNCTION(xmms_is_repeat); PHP_FUNCTION(xmms_repeat); PHP_FUNCTION(xmms_is_shuffle); PHP_FUNCTION(xmms_shuffle); PHP_FUNCTION(xmms_add); PHP_FUNCTION(xmms_delete); PHP_FUNCTION(xmms_clear); PHP_FUNCTION(xmms_current); PHP_FUNCTION(xmms_volume); PHP_FUNCTION(xmms_url); PHP_FUNCTION(xmms_skin); PHP_FUNCTION(xmms_time); ZEND_BEGIN_MODULE_GLOBALS(xmms) int session; ZEND_END_MODULE_GLOBALS(xmms) /* In every function that needs to use variables in php_xmms_globals, call TSRM_FETCH(); after declaring other variables used by that function, and always refer to them as XMMS_G(variable). You are encouraged to rename these macros something shorter, see examples in any other php module directory. */ #ifdef ZTS #define XG(v) TSRMG(xmms_globals_id, zend_xmms_globals *, v) #else #define XG(v) (xmms_globals.v) #endif #endif /* PHP_XMMS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: */ Index: pear/XMMS/xmms.c +++ pear/XMMS/xmms.c /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_xmms.h" /* If you declare any globals in php_xmms.h uncomment this: ZEND_DECLARE_MODULE_GLOBALS(xmms) */ /* {{{ xmms_functions[] * * Every user visible function must have an entry in xmms_functions[]. */ function_entry xmms_functions[] = { PHP_FE(xmms_start, NULL) PHP_FE(xmms_playlist_pos, NULL) PHP_FE(xmms_playlist, NULL) PHP_FE(xmms_play, NULL) PHP_FE(xmms_stop, NULL) PHP_FE(xmms_pause, NULL) PHP_FE(xmms_quit, NULL) PHP_FE(xmms_version, NULL) PHP_FE(xmms_next, NULL) PHP_FE(xmms_prev, NULL) PHP_FE(xmms_status, NULL) PHP_FE(xmms_is_repeat, NULL) PHP_FE(xmms_repeat, NULL) PHP_FE(xmms_is_shuffle, NULL) PHP_FE(xmms_shuffle, NULL) PHP_FE(xmms_add, NULL) PHP_FE(xmms_delete, NULL) PHP_FE(xmms_clear, NULL) PHP_FE(xmms_current, NULL) PHP_FE(xmms_volume, NULL) PHP_FE(xmms_url, NULL) PHP_FE(xmms_skin, NULL) PHP_FE(xmms_time, NULL) {NULL, NULL, NULL} /* Must be the last line in xmms_functions[] */ }; /* }}} */ /* {{{ xmms_module_entry */ zend_module_entry xmms_module_entry = { "xmms", xmms_functions, PHP_MINIT(xmms), PHP_MSHUTDOWN(xmms), NULL, NULL, PHP_MINFO(xmms), STANDARD_MODULE_PROPERTIES }; /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(xmms) #ifdef COMPILE_DL_XMMS ZEND_GET_MODULE(xmms) #endif /* {{{ php_xmms_init_globals */ static void php_xmms_init_globals(zend_xmms_globals *xmms_globals) { xmms_globals->session = 0; } /* }}} */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("xmms.session", "0", PHP_INI_ALL, OnUpdateInt, session, zend_xmms_globals, xmms_globals) PHP_INI_END() /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(xmms) { ZEND_INIT_MODULE_GLOBALS(xmms, php_xmms_init_globals, NULL); REGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(xmms) { UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(xmms) { char buf[16]; int running, pos; php_info_print_table_start(); php_info_print_table_header(2, "xmms support", "enabled"); running = xmms_remote_is_running(XG(session)); if(running) { if(xmms_remote_is_paused(XG(session))) { php_info_print_table_row(2, "XMMS Status", "Paused"); } else { if(xmms_remote_is_playing(XG(session))) { php_info_print_table_row(2, "XMMS Status", "Playing"); } else { php_info_print_table_row(2, "XMMS Status", "Stopped"); } } sprintf(buf, "%d", xmms_remote_get_version(XG(session))); php_info_print_table_row(2, "XMMS Version", buf); pos = xmms_remote_get_playlist_pos(XG(session)); sprintf(buf, "%d", pos); php_info_print_table_row(2, "Current Playlist Entry #", buf); php_info_print_table_row(2, "Current Song", xmms_remote_get_playlist_title(XG(session), pos)); php_info_print_table_row(2, "Current Filename", xmms_remote_get_playlist_file(XG(session), pos)); sprintf(buf, "%.3f", (double)(xmms_remote_get_playlist_time(XG(session), pos)/1000.0)); php_info_print_table_row(2, "Current Song Length", buf); sprintf(buf, "%.3f", (double)(xmms_remote_get_output_time(XG(session))/1000.0)); php_info_print_table_row(2, "Current Song Position", buf); } else { php_info_print_table_row(2, "XMMS Status", "Not Running"); } php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } /* }}} */ /* {{{ proto int xmms_start(void) Start up XMMS if it is not already running */ PHP_FUNCTION(xmms_start) { pid_t pid; char *av[] = { "xmms",NULL }; if(!xmms_remote_is_running(XG(session))) { /* Ok, this is pretty weird, but hey, why not? */ pid = fork(); if(pid > 0) { daemon(1,0); if(execve("/usr/bin/xmms",av,environ)==-1) { php_error(E_WARNING, "Unable to exec XMMS"); exit(-1); } } else if(pid==0) sleep(1); else if(pid==-1) { php_error(E_WARNING, "Unable to fork XMMS"); RETURN_FALSE; } } if(xmms_remote_is_running(XG(session))) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int xmms_playlist_pos(void) Get current playlist position */ PHP_FUNCTION(xmms_playlist_pos) { RETURN_LONG(xmms_remote_get_playlist_pos(XG(session))); } /* }}} */ /* {{{ proto array xmms_playlist([int pos]) Get full playlist */ PHP_FUNCTION(xmms_playlist) { zval **pos_arg; int pos, len, i; int argc = ZEND_NUM_ARGS(); pval *tmp; if (argc > 1 || (argc && zend_get_parameters_ex(argc, &pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); /* Fall-through. */ case 0: break; } array_init(return_value); if(!argc) { len = xmms_remote_get_playlist_length(XG(session)); for(i=0; i<len; i++) { MAKE_STD_ZVAL(tmp); array_init(tmp); add_assoc_string(tmp, "title", xmms_remote_get_playlist_title(XG(session),i), 1); add_assoc_string(tmp, "file", xmms_remote_get_playlist_file(XG(session),i), 1); add_assoc_double(tmp, "time", xmms_remote_get_playlist_time(XG(session),i)/1000.0); zend_hash_index_update(return_value->value.ht, i, &tmp, sizeof(tmp), NULL); } } else { array_init(return_value); add_assoc_string(return_value, "title", xmms_remote_get_playlist_title(XG(session),pos), 1); add_assoc_string(return_value, "file", xmms_remote_get_playlist_file(XG(session),pos), 1); add_assoc_double(return_value, "time", xmms_remote_get_playlist_time(XG(session),pos)/1000.0); } } /* }}} */ /* {{{ proto void xmms_play([int pos]) */ PHP_FUNCTION(xmms_play) { zval **pos_arg; int pos; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); xmms_remote_set_playlist_pos(XG(session), pos); /* Fall-through. */ case 0: xmms_remote_play(XG(session)); break; } } /* }}} */ /* {{{ proto void xmms_stop() Stop playing current song */ PHP_FUNCTION(xmms_stop) { xmms_remote_stop(XG(session)); } /* }}} */ /* {{{ proto xmms_pause(void) Pause current song (toggle) */ PHP_FUNCTION(xmms_pause) { xmms_remote_pause(XG(session)); } /* }}} */ /* {{{ proto void xmms_quit(void) Force XMMS to terminate */ PHP_FUNCTION(xmms_quit) { xmms_remote_quit(XG(session)); } /* }}} */ /* {{{ proto int xmms_version(void) Get the XMMS version */ PHP_FUNCTION(xmms_version) { int version; version = xmms_remote_get_version(XG(session)); RETURN_LONG(version); } /* }}} */ /* {{{ proto void xmms_next(void) Go to next song in playlist */ PHP_FUNCTION(xmms_next) { xmms_remote_playlist_next(XG(session)); } /* }}} */ /* {{{ proto void xmms_prev(void) Go to previous song in playlist */ PHP_FUNCTION(xmms_prev) { xmms_remote_playlist_prev(XG(session)); } /* }}} */ /* {{{ proto string xmms_status(void) Returns current XMMS status */ PHP_FUNCTION(xmms_status) { int playing, paused; playing = xmms_remote_is_playing(XG(session)); paused = xmms_remote_is_paused(XG(session)); if(paused) { RETURN_STRINGL("Paused",6,1); } else { if(playing) { RETURN_STRINGL("Playing",7,1); } else { RETURN_STRINGL("Stopped",7,1); } } } /* }}} */ /* {{{ proto bool xmms_is_repeat(void) Get repeat setting */ PHP_FUNCTION(xmms_is_repeat) { RETURN_BOOL(xmms_remote_is_repeat(XG(session))); } /* }}} */ /* {{{ proto int xmms_repeat([int setting]) Toggle/Set repeat setting */ PHP_FUNCTION(xmms_repeat) { zval **setting_arg; int setting; gboolean current; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &setting_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(setting_arg); setting = Z_LVAL_PP(setting_arg); if(setting) setting=TRUE; else setting=FALSE; /* Fall-through. */ case 0: break; } if(argc) { current = xmms_remote_is_repeat(XG(session)); if(current) current=TRUE; else current=FALSE; if(current != setting) { xmms_remote_toggle_repeat(XG(session)); } } else { setting = !xmms_remote_is_repeat(XG(session)); xmms_remote_toggle_repeat(XG(session)); } RETURN_BOOL(setting); } /* }}} */ /* {{{ proto bool xmms_is_shuffle(void) Get shuffle setting */ PHP_FUNCTION(xmms_is_shuffle) { RETURN_BOOL(xmms_remote_is_shuffle(XG(session))); } /* }}} */ /* {{{ proto int xmms_shuffle([int setting]) Toggle/Set shuffle setting*/ PHP_FUNCTION(xmms_shuffle) { zval **setting_arg; int setting; gboolean current; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &setting_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_long_ex(setting_arg); setting = Z_LVAL_PP(setting_arg); if(setting) setting=TRUE; else setting=FALSE; /* Fall-through. */ case 0: break; } if(argc) { current = xmms_remote_is_shuffle(XG(session)); if(current) current=TRUE; else current=FALSE; if(current != setting) { xmms_remote_toggle_shuffle(XG(session)); } } else { setting = !xmms_remote_is_shuffle(XG(session)); xmms_remote_toggle_shuffle(XG(session)); } RETURN_BOOL(setting); } /* }}} */ /* {{{ proto xmms_add(mixed songs) Add entries to playlist */ PHP_FUNCTION(xmms_add) { zval **songs_arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &songs_arg) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } /* Write your own code here to handle argument songs. */ php_error(E_WARNING, "xmms_add: not yet implemented"); } /* }}} */ /* {{{ proto xmms_delete(int pos) Delete entry from playlist */ PHP_FUNCTION(xmms_delete) { zval **pos_arg; int pos; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pos_arg) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } convert_to_long_ex(pos_arg); pos = Z_LVAL_PP(pos_arg); php_error(E_WARNING, "xmms_delete: not yet implemented"); } /* }}} */ /* {{{ proto xmms_clear() Clear playlist */ PHP_FUNCTION(xmms_clear) { php_error(E_WARNING, "xmms_clear: not yet implemented"); } /* }}} */ /* {{{ proto array xmms_current(void) Get current song info */ PHP_FUNCTION(xmms_current) { long pos, time, timepos; char *fn, *title; int rate, freq, nch; int playing, paused, repeat, shuffle; char status[10]; playing = xmms_remote_is_playing(XG(session)); paused = xmms_remote_is_paused(XG(session)); timepos = xmms_remote_get_output_time(XG(session)); pos = xmms_remote_get_playlist_pos(XG(session)); fn = xmms_remote_get_playlist_file(XG(session), pos); title = xmms_remote_get_playlist_title(XG(session), pos); time = xmms_remote_get_playlist_time(XG(session), pos); repeat = xmms_remote_is_repeat(XG(session)); shuffle = xmms_remote_is_shuffle(XG(session)); if(paused) strcpy(status,"Paused"); else { if(playing) strcpy(status,"Playing"); else strcpy(status,"Stopped"); } xmms_remote_get_info(XG(session), &rate, &freq, &nch); array_init(return_value); add_assoc_long(return_value, "pos", pos); add_assoc_string(return_value, "file", fn, 1); add_assoc_string(return_value, "title", title, 1); add_assoc_double(return_value, "time", (double)(time/1000.0)); add_assoc_double(return_value, "timepos", (double)(timepos/1000.0)); add_assoc_string(return_value, "status", status, 1); add_assoc_bool(return_value, "repeat", repeat); add_assoc_bool(return_value, "shuffle", shuffle); add_assoc_long(return_value, "rate", rate); add_assoc_long(return_value, "freq", freq); add_assoc_long(return_value, "nch", nch); } /* }}} */ /* {{{ proto xmms_volume([int level [, int right_level]]) */ PHP_FUNCTION(xmms_volume) { zval **level_arg, **right_level_arg; int level; int right_level; int argc = ZEND_NUM_ARGS(); if (argc > 2 || (argc && zend_get_parameters_ex(argc, &level_arg, &right_level_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 2: convert_to_long_ex(right_level_arg); right_level = Z_LVAL_PP(right_level_arg); /* Fall-through. */ case 1: convert_to_long_ex(level_arg); level = Z_LVAL_PP(level_arg); /* Fall-through. */ case 0: break; } php_error(E_WARNING, "xmms_volume: not yet implemented"); } /* }}} */ /* {{{ proto void xmms_url(string url) Play from url */ PHP_FUNCTION(xmms_url) { zval **url; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &url) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } convert_to_string_ex(url); /* this add_url call doesn't seem to work - not sure why yet */ xmms_remote_playlist_add_url_string(XG(session),Z_STRVAL_PP(url)); } /* }}} */ /* {{{ proto xmms_skin([string skin_file]) */ PHP_FUNCTION(xmms_skin) { zval **skin_file_arg; char *skin_file = NULL; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &skin_file_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_string_ex(skin_file_arg); skin_file = Z_STRVAL_PP(skin_file_arg); /* Fall-through. */ case 0: break; } php_error(E_WARNING, "xmms_skin: not yet implemented"); } /* }}} */ /* {{{ proto float xmms_time([float time_pos]) Get/Set output time position */ PHP_FUNCTION(xmms_time) { zval **time_pos_arg; double time_pos; int argc = ZEND_NUM_ARGS(); if (argc > 1 || (argc && zend_get_parameters_ex(argc, &time_pos_arg) == FAILURE)) { ZEND_WRONG_PARAM_COUNT(); } switch (argc) { case 1: convert_to_double_ex(time_pos_arg); time_pos = Z_DVAL_PP(time_pos_arg); xmms_remote_jump_to_time(XG(session), (int)(time_pos*1000)); RETVAL_DOUBLE(time_pos); /* Fall-through. */ case 0: RETVAL_DOUBLE((double)(xmms_remote_get_output_time(XG(session))/1000.0)); break; } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: sw=4 ts=4 tw=78 fdm=marker * vim<600: sw=4 ts=4 tw=78 */ Index: pear/XMMS/xmms.glade +++ pear/XMMS/xmms.glade <?xml version="1.0"?> <GTK-Interface> <project> <name>Xmms</name> <program_name>xmms</program_name> <directory></directory> <source_directory>src</source_directory> <pixmaps_directory>pixmaps</pixmaps_directory> <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> <output_main_file>False</output_main_file> <output_support_files>False</output_support_files> <output_build_files>False</output_build_files> </project> <widget> <class>GtkWindow</class> <name>xmms</name> <signal> <name>destroy</name> <handler>destroy</handler> <last_modification_time>Thu, 09 Aug 2001 15:21:09 GMT</last_modification_time> </signal> <signal> <name>delete_event</name> <handler>delete_event</handler> <last_modification_time>Thu, 09 Aug 2001 15:21:47 GMT</last_modification_time> </signal> <signal> <name>destroy_event</name> <handler>destroy</handler> <last_modification_time>Thu, 09 Aug 2001 15:22:09 GMT</last_modification_time> </signal> <title>PHP-XMMS</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> <modal>False</modal> <allow_shrink>False</allow_shrink> <allow_grow>False</allow_grow> <auto_shrink>False</auto_shrink> <widget> <class>GtkAlignment</class> <name>alignment1</name> <xalign>0.5</xalign> <yalign>0.5</yalign> <xscale>1</xscale> <yscale>1</yscale> <widget> <class>GtkTable</class> <name>table1</name> <rows>3</rows> <columns>4</columns> <homogeneous>False</homogeneous> <row_spacing>0</row_spacing> <column_spacing>0</column_spacing> <widget> <class>GtkButton</class> <name>prev</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_prev_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 17:19:37 GMT</last_modification_time> </signal> <label>Previous</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>0</left_attach> <right_attach>1</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>next</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_next_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 05:14:19 GMT</last_modification_time> </signal> <label>Next</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>3</left_attach> <right_attach>4</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>play</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_play_clicked</handler> <last_modification_time>Thu, 09 Aug 2001 05:41:35 GMT</last_modification_time> </signal> <label>Play</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkButton</class> <name>pause</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>xmms_pause</handler> <last_modification_time>Thu, 09 Aug 2001 05:38:57 GMT</last_modification_time> </signal> <label>Pause</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <left_attach>2</left_attach> <right_attach>3</right_attach> <top_attach>2</top_attach> <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkToggleButton</class> <name>shuffle</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>toggled</name> <handler>on_shuffle_toggled</handler> <last_modification_time>Thu, 09 Aug 2001 05:51:09 GMT</last_modification_time> </signal> <label>Shuffle</label> <relief>GTK_RELIEF_HALF</relief> <active>False</active> <child> <left_attach>2</left_attach> <right_attach>3</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkToggleButton</class> <name>repeat</name> <border_width>1</border_width> <can_focus>True</can_focus> <signal> <name>toggled</name> <handler>on_repeat_toggled</handler> <last_modification_time>Thu, 09 Aug 2001 05:52:25 GMT</last_modification_time> </signal> <label>Repeat</label> <relief>GTK_RELIEF_HALF</relief> <active>False</active> <child> <left_attach>3</left_attach> <right_attach>4</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkProgressBar</class> <name>time</name> <value>0</value> <lower>0</lower> <upper>100</upper> <bar_style>GTK_PROGRESS_CONTINUOUS</bar_style> <orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation> <activity_mode>False</activity_mode> <show_text>True</show_text> <format>%vs (%p%%)</format> <text_xalign>0.5</text_xalign> <text_yalign>0.5</text_yalign> <child> <left_attach>0</left_attach> <right_attach>2</right_attach> <top_attach>1</top_attach> <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> <widget> <class>GtkLabel</class> <name>status</name> <label></label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0</xalign> <yalign>0.5</yalign> <xpad>2</xpad> <ypad>2</ypad> <child> <left_attach>0</left_attach> <right_attach>4</right_attach> <top_attach>0</top_attach> <bottom_attach>1</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> <yfill>False</yfill> </child> </widget> </widget> </widget> </widget> </GTK-Interface>