[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Streaming with the Movie module



I am trying to get pyGame to play an mpeg that I am 'streaming' across a 
socket.  The script reads 100KB chunks from the socket and writes it to a 
file (download.mpg).  After the first chunk is read, the script starts 
playing the movie from the file.  The problem is that the movie only plays 
for a short time (it looks like only the first chunk is played).

Does anyone know what is going on here and/or what I can do to get the whole 
file to play (as I send it across the socket)?

TIA,
LGL

btw, python2.2 on redhat linux 7.3 and pygame 1.5.6 and source below...

#---------------------------------------------------------------------
			init=0
			receiving=1
			self.mpegFile=open('download.mpg','wba')

			while receiving:
				try:
					chunk=self.clt_sock.recv(1024*100)
					self.mpegFile.write(chunk)
					if init==0:
						movPos=Rect(20,60,320,240)
						self.mov = Movie('download.mpg')
						self.mov.set_display(self.screen, movPos)
						self.mov.play()
						init=1

				except:
					receiving=0
					print "No chunks on socket"

				time.sleep(1.0)
			print "Socket stopped reading"

			self.mpegFile.close()
#---------------------------------------------------------------------