Commits

Anonymous committed 0d198d6

Added "finished" member to the movie player. Will be true when the video
has finished playing.

Comments (0)

Files changed (5)

 m = movie.Movie(filename)
 print m.paused  #always False, unless .pause has been called
 print m.playing #False until play has been called. Will return to false when
-                # .stop() has been called.
+print m.finished# .stop() has been called.
                 
 print m.width   #default size values of the video file
 print m.height  # They can be modified on the fly, as will be demonstrated.
 actions = {1: lambda x: x.paused, 6: lambda x:x.pause(), 11: lambda x:x.pause(), 15: lambda x: x.resize(int(x.width*0.9), int(x.height*0.9)), 2000:lambda x: x.stop(), 3000: lambda x: x.play(-1)}
 m.play(-1)
 prev_time = time.time()
+#m.resize(m.width*2, m.height*2)
 #m.surface = screen
 print "About to do surface gymnastics..."
+##while 1:
+##    time.sleep(0.1)
+##    pygame.display.update()
+
 while(1):
     new_time=time.time()
     diff = int(new_time-prev_time)
 	 * 		read frame
 	 * 		load frame into A/V queue
 	 * 		video_render()
-	 * 		audio_thread()
+	 * 		//audio_thread()
 	 * 		first two loops:
 	 * 			video_refresh_timer <--- we do this or else we'd never start display frames
 	 * 		if timing AND timing >=now:
     int ret;
     AVPacket pkt1, *pkt = &pkt1;
     movie->stop=0;
+    movie->finished =0;
     ic=movie->ic;
     int co=0;
     movie->last_showtime = av_gettime()/1000.0;
     }
     movie->pictq_size=movie->pictq_rindex=movie->pictq_windex=0;
     packet_queue_flush(&movie->videoq);
-
+	movie->finished=1;
     GRABGIL
     Py_DECREF( movie);
     RELEASEGIL
     int              stop;           //whether we're in a stop state...
     SDL_Surface     *canon_surf;     //pointer to the surface given by the programmer. We do NOT free this... it is not ours. We just write to it.
     PyThreadState   *_tstate;        //really do not touch this unless you have to. This is used for threading control and primitives.
-
+	int finished;
     int diff_co; //counter
 
     /* Seek-info */
     return pyo;
 }
 
+PyObject* _movie_get_finished(PyMovie *movie,  void *closure)
+{
+	return PyBool_FromLong((long)movie->finished);	
+}
+
 PyObject* _movie_get_width (PyMovie *movie, void *closure)
 {
     PyObject *pyo;
 
 static PyGetSetDef _movie_getsets[] =
     {
-        { "paused",  (getter) _movie_get_paused,  NULL,                        DOC_GMOVIEMOVIEPAUSE,   NULL },
-        { "playing", (getter) _movie_get_playing, NULL,                        DOC_GMOVIEMOVIEPLAYING, NULL },
-        { "height",  (getter) _movie_get_height,  (setter) _movie_set_height,  DOC_GMOVIEMOVIEHEIGHT,  NULL },
-        { "width",   (getter) _movie_get_width,   (setter) _movie_set_width,   DOC_GMOVIEMOVIEWIDTH,   NULL },
-        { "surface", (getter) _movie_get_surface, (setter) _movie_set_surface, DOC_GMOVIEMOVIESURFACE, NULL },
-        { NULL,      NULL,                        NULL,                        NULL,                   NULL }
+        { "paused",   (getter) _movie_get_paused,   NULL,                       DOC_GMOVIEMOVIEPAUSE,   NULL },
+        { "playing",  (getter) _movie_get_playing,  NULL,                       DOC_GMOVIEMOVIEPLAYING, NULL },
+        { "finished", (getter) _movie_get_finished, NULL,                       NULL,                   NULL },
+        { "height",   (getter) _movie_get_height,  (setter) _movie_set_height,  DOC_GMOVIEMOVIEHEIGHT,  NULL },
+        { "width",    (getter) _movie_get_width,   (setter) _movie_set_width,   DOC_GMOVIEMOVIEWIDTH,   NULL },
+        { "surface",  (getter) _movie_get_surface, (setter) _movie_set_surface, DOC_GMOVIEMOVIESURFACE, NULL },
+        { NULL,       NULL,                        NULL,                        NULL,                   NULL }
     };
 
 static PyTypeObject PyMovie_Type =
 /* Getters/setters */
 PyObject* _movie_get_paused  (PyMovie *movie, void *closure);
 PyObject* _movie_get_playing (PyMovie *movie, void *closure);
+PyObject* _movie_get_finished(PyMovie *movie,  void *closure);
 PyObject* _movie_get_width   (PyMovie *movie, void *closure);
 int       _movie_set_width   (PyMovie *movie, PyObject *width, void *closure);
 PyObject* _movie_get_height  (PyMovie *movie, void *closure);