Streaming with Android MediaPlayer in SDK 8

后端 未结 2 1877
悲&欢浪女
悲&欢浪女 2021-01-31 21:53

SDK level 8 (Froyo) has introduced the native capability for the MediaPlayer to connect to a streaming source, like Shoutcast. Previous SDK versions were able to do workarounds,

相关标签:
2条回答
  • 2021-01-31 22:02

    MediaPlayer streaming is available since API level 1. I did a demo RTSP video player about year and a half ago. Nagare shoutcast client is now already two years old.

    Am I missing something here?

    0 讨论(0)
  • 2021-01-31 22:08

    EDIT: Ok I now believe I have the answer!

    Stagefright is strict when it comes to line-endings in the HTTP-header; They have to be CR,LF and not just LF which has worked earlier.

    So if you build your own headers, replace any "\n" with "\r\n" and you should be fine.

    (If you want to check this for yourself, look at receive_line() in media/libstagefright/HTTPStream.cpp)

    I can now stream shoutcast with Metadata on 2.2/Stagefright phones...

    ...

    I have been running into the same problem;

    First I tried writing the streamed data to a fixed length file and wrapping - and playing it with setLooping(true). This causes glitches when the MP3 loops, even though I extract whole MP3 frames and tried to pad the uneven bytes at the end with both 0xff and 0x00. This might still be an acceptable solution if you have a big enough file.

    Then I did the proxy thing which works on my Samsung Galaxy S (v2.2) but not in the emulator and apparently not on the Desire (Not working = Error -1007 as mentioned above). One hint may be that the Galaxy S Mediaplayer asks for HTTP1.0, while it is 1.1 in the emulator.

    The brute-force method would be to open 2 streams in parallel, reading meta-data from one and streaming from the other ;)

    Anyway, I also want to hear if anyone else has had more luck...

    0 讨论(0)
提交回复
热议问题