Anonymous committed 7250e77

music finished event added

Comments (0)

Files changed (4)

-TODO list for the 1.0 release:
+Pygame is currently aiming for a 1.0 release near the end of the year.
+This doesn't mean pygame is in a useless state, it is in fact getting
+quite robust.
- * Joystick and CDROM modules need to be cleaned up
- * Support for OpenGL
- * Support for Piddle
- * More testing and general usage cleanup
- * Surfarray with alpha and colormap support
-The plan is to ramp up to a 1.0 release within a couple months. At
-that point the only real plan will be keeping in stride with SDL
-and other dependency version releases.
+At this point the biggest needs are to get the functionality for
+all of SDL and the other libraries fully covered. We're almost there,
+but still need to get the more esoteric functions all wrapped up.
+The functions you'll need for 95% of your projects is already done.
 Until that point, consider the current interface to be a bit flexible.
 Things could change that will break code relying on older versions. Any
 changes will be easy to make. There will be warning of coming changes,
-but just know that it will likely happen.
+but just know that it will likely happen.
+Here are some main things i'd like to have done (or at least well
+looked at) by the time 1.0 rolls around. Most of these are ideas
+for covering other libraries and routiens SDL does not offer.
+ * Joystick and CDROM modules cleaned up
+ * Support for OpenGL (need to experiment with pyopengl)
+ * Support for Piddle (drawing lines, shapes, text)
+ * Surfarray with alpha and colormap support
+ * Interface with PIL images
+ * GUI library. There's a few out there, this is a biggie
+ * Simple image transforms; flip, rotate-90, double
      Nov 14, 2000
 	Release the Python Global Interpreter Lock on delays and IO
 	Added timer events to pygame.time (vgrade example demonstrates)
+	New music playback finished events
 	Documentation reorganized, 1st tutorial added
 	surfarray.blit_array() supports all bit depths


 def main():
     size = 640, 480
-    screen = pygame.display.set_mode(size, 0, 24)
+    screen = pygame.display.set_mode(size)
     pygame.event.set_blocked(MOUSEMOTION) #keep our queue cleaner
     pygame.time.set_timer(500, USEREVENT)
- *  mixer module for PyGAME
+ *  music module for PyGAME
 #include "pygame.h"
 static Mix_Music* current_music = NULL;
+static int endmusic_event = SDL_NOEVENT;
+static void endmusic_callback()
+	if(endmusic_event && SDL_WasInit(SDL_INIT_VIDEO))
+	{
+		SDL_Event e = {endmusic_event};
+		SDL_PushEvent(&e);
+	}
 static void autoquit()
 static PyObject* autoinit(PyObject* self, PyObject* arg)
-	return PyMixer_AutoInit(self, arg);
+	PyObject* ret = PyMixer_AutoInit(self, arg);
+	if(PyObject_IsTrue(ret))
+		Mix_HookMusicFinished(endmusic_callback);
+	return ret;
+    /*DOC*/ static char doc_set_endevent[] =
+    /*DOC*/    "[eventid]) -> None\n"
+    /*DOC*/    "sets music finished event\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "When the music has finished playing, you can optionally have\n"
+    /*DOC*/    "pygame place a user defined message on the event queue. If the\n"
+    /*DOC*/    "eventid field is omittied or NOEVENT, no messages will be sent\n"
+    /*DOC*/    "when the music finishes playing. Once the endevent is set, it\n"
+    /*DOC*/    "will be called every time the music finished playing.\n"
+    /*DOC*/ ;
+static PyObject* set_endevent(PyObject* self, PyObject* args)
+	int eventid = SDL_NOEVENT;
+	if(!PyArg_ParseTuple(args, "i", &eventid))
+		return NULL;
+	endmusic_event = eventid;
+    /*DOC*/ static char doc_get_endevent[] =
+    /*DOC*/    "[eventid]) -> int\n"
+    /*DOC*/    "query the current music finished event\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "When the music has finished playing, you can optionally have\n"
+    /*DOC*/    "pygame place a user defined message on the event queue. If there\n"
+    /*DOC*/    "is no callback event set, NOEVENT will be returned. Otherwise it\n"
+    /*DOC*/    "will return the id of the current music finishe event.\n"
+    /*DOC*/ ;
+static PyObject* get_endevent(PyObject* self, PyObject* args)
+	if(!PyArg_ParseTuple(args, ""))
+		return NULL;
+	return PyInt_FromLong(endmusic_event);
     /*DOC*/ static char doc_load[] =
     /*DOC*/    " -> None\n"
 	{ "quit", quit, 1, doc_quit },
 	{ "get_init", get_init, 1, doc_get_init },
-/*	{ "music_endevent", music_endevent, 1, doc_music_endevent },*/
+	{ "set_endevent", set_endevent, 1, doc_set_endevent },
+	{ "get_endevent", get_endevent, 1, doc_get_endevent },
 	{ "play", play, 1, doc_play },
 	{ "get_busy", get_busy, 1, doc_get_busy },
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.