Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play video in Android from a bytes stream

Is there any way to play a video from a bytes stream in Android? I'm using an specific communications middleware so I can't just pass the http/rtsp link to the MediaPlayer object.

I was wondering if I can wrap my stream with a local http/rtsp link so I can play the stream instead of waiting until the file is downloaded to play it.

My middleware works over TCP so I've also thought that I can wrap my rtsp datagrams with a tcp datagram and interpret them on the client somehow, after removing the TCP headers.

I'm really surprised that I can't just pass a bytes stream to the MediaPlayer. Thanks in advance.

like image 680
Pedriyoo Avatar asked Feb 01 '11 11:02

Pedriyoo


1 Answers

Custom streaming in Android isn't as easy as I thought. I've managed to do it but only with very specific videos. MPEG4 Videos that are poorly interleaved seem to be streamable. The farest I've gotten is streaming this video:

http://www.pocketjourney.com/downloads/pj/video/famous.3gp

As Cipi answered me, most formats cannot just be packed in a bytes buffer and pass it to MediaPlayer. They need some headers, tails, etc. I'm not sure which format is contained within the aforementioned file, but I guess it's MPEG4.

like image 184
Pedriyoo Avatar answered Sep 24 '22 18:09

Pedriyoo