Play video in Android from a bytes stream

你说的曾经没有我的故事 提交于 2019-12-04 19:17:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4861805/play-video-in-android-from-a-bytes-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!