Anonymous avatar Anonymous committed 9cbfcba

cursor and movie updates

Comments (0)

Files changed (7)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+September 2, 2002
+	add Movie.render_frame, thanks James Mazer
+	cursors.load_xbm skips comments, thanks Herve
+
 August 20, 2002
 	fix rectstyle arguments
 
 <a href=ref/Movie.html#has_video>Movie.has_video</a> - query if movie stream has video<br>
 <a href=ref/Movie.html#pause>Movie.pause</a> - pause/resume movie playback<br>
 <a href=ref/Movie.html#play>Movie.play</a> - start movie playback<br>
+<a href=ref/Movie.html#render_frame>Movie.render_frame</a> - Render a specfic numbered frame.<br>
 <a href=ref/Movie.html#rewind>Movie.rewind</a> - set playback position to the beginning of the movie<br>
 <a href=ref/Movie.html#set_display>Movie.set_display</a> - change the video output surface<br>
 <a href=ref/Movie.html#set_volume>Movie.set_volume</a> - change volume for sound<br>

docs/ref/Movie.html

 start movie playback</td></tr>
 
 
+<tr><td><a href=#render_frame>render_frame</a></td><td> -
+Render a specfic numbered frame.</td></tr>
+
+
 <tr><td><a href=#rewind>rewind</a></td><td> -
 set playback position to the beginning of the movie</td></tr>
 
 number of times the movie loops while playing.
 </ul><br>&nbsp;<br>
 
+<a name=render_frame><font size=+2><b>render_frame
+</b></font><br><font size=+1><tt>
+Movie.render_frame(framenum) -> int
+</tt></font><ul>
+Returns the current frame number.
+</ul><br>&nbsp;<br>
+
 <a name=rewind><font size=+2><b>rewind
 </b></font><br><font size=+1><tt>
 Movie.rewind() -> None
     if type(mask) is type(''): mask = open(mask)
     curs = curs.readlines()
     mask = mask.readlines()
+    #avoid comments
+    for line in range(len(curs)):
+        if curs[line].startswith("#define"):
+            curs = curs[line:]
+            break
+    for line in range(len(mask)):
+    	if mask[line].startswith("#define"):
+            mask = mask[line:]
+            break
     #load width,height
     width = int(curs[0].split()[-1])
     height = int(curs[1].split()[-1])
     Niki Spahiev, Gordon Tyler, Nathaniel Pryce, 
     Dave Wallace, John Popplewell, Michael Urman,
     Andrew Straw, Michael Hudson, Ole Martin Bjoerndalen,
-    Herv� Cauwelier</li>
+    Herv� Cauwelier, James Mazer</li>
 <li>And our bug hunters above and beyond:
     Angus, Guillaume Proux, Frank Raiser,
     Austin Henry, Kaweh Kazemi, Arturo Aldama,
 <li>quake-like console with python interpreter</li>
 <li>game lobby. client, simple server, and protocol</li>
 <li>surfarrays should be able to do RGBA along with RGB</li>
+<li>draw with transparancy</li>
+<li>draw large sets of primitives with a single call</li>
 </ul></p><br>
 
 
      * quake-like console with python interpreter
      * game lobby. client, simple server, and protocol
      * surfarrays should be able to do RGBA along with RGB
+     * draw with transparancy
+     * draw large sets of primitives with a single call
 
    License
 
 }
 
 
+
+    /*DOC*/ static char doc_movie_render_frame[] =
+    /*DOC*/    "Movie.render_frame(framenum) -> int\n"
+    /*DOC*/    "Render a specfic numbered frame.\n"    
+    /*DOC*/    "\n"                                
+    /*DOC*/    "Returns the current frame number.\n"                  
+    /*DOC*/ ;                    
+             
+static PyObject* movie_render_frame(PyObject* self, PyObject* args)
+{            
+        SMPEG* movie = PyMovie_AsSMPEG(self);
+        SMPEG_Info info;                     
+        int framenum;   
+                     
+        if(!PyArg_ParseTuple(args, "i", &framenum))
+                return NULL;                       
+        Py_BEGIN_ALLOW_THREADS
+        SMPEG_renderFrame(movie, framenum);
+        SMPEG_getinfo(movie, &info);       
+        Py_END_ALLOW_THREADS        
+        return PyInt_FromLong(info.current_frame);
+}
+
+
 static PyMethodDef movie_builtins[] =
 {
 	{ "play", movie_play, 1, doc_movie_play },
 	{ "get_time", movie_get_time, 1, doc_movie_get_time },
 	{ "get_length", movie_get_length, 1, doc_movie_get_length },
 	{ "get_busy", movie_get_busy, 1, doc_movie_get_busy },
+        { "render_frame", movie_render_frame, 1, doc_movie_render_frame},
 
 	{ NULL, NULL }
 };
     /*DOC*/    "and play your movie. Finally calling pygame.mixer.init()\n"
     /*DOC*/    "again when finished with the Movie.\n"
     /*DOC*/    "\n"
+    /*DOC*/    "NOTE: When disabling the mixer so a movie may play audio,\n"
+    /*DOC*/    "you must disable the audio before calling pygame.movie.Movie\n"
+    /*DOC*/    "or the movie will not realise that it may access the audio.\n"
+    /*DOC*/    "Before reinitialising the mixer, You must remove all\n"
+    /*DOC*/    "references to the movie before calling pygame.mixer.init()\n"
+    /*DOC*/    "or the init will fail, leading to errors when you attempt to\n"
+    /*DOC*/    "use the mixer.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "eg.\n"
+    /*DOC*/    "pygame.mixer.quit()\n"
+    /*DOC*/    "movie=pygame.movie.Movie(\"my.mpg\")\n"
+    /*DOC*/    "movie.play()\n"
+    /*DOC*/    "# process events until movie finished here\n"
+    /*DOC*/    "movie.stop()\n"
+    /*DOC*/    "movie=None # if you don't do this bit the init will fail\n"
+    /*DOC*/    "pygame.mixer.init()\n"
     /*DOC*/ ;
 
 static PyTypeObject PyMovie_Type =
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 ProjectModifiedEvent.java.
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.