开发者

Android MediaPlayer streaming MP3 over POST

开发者 https://www.devze.com 2023-01-17 00:46 出处:网络
I\'ve got a question related to the Android MediaPlay开发者_如何转开发er. Can it stream content through HTTP POST method , or do I have to write my own implementation? If so, what SDK do I have to use

I've got a question related to the Android MediaPlay开发者_如何转开发er. Can it stream content through HTTP POST method , or do I have to write my own implementation? If so, what SDK do I have to use?

Thanks in advance.


If I understand you correct, the URL you want to supply will return some sort of media? This trick worked for me with a 3gp file. Assuming the HTTP POST request parameters will be feed through the URL.

URL url = new URL("insert-url-path-here");
URLConnection con = url.openConnection();
con.connect();
con.getContent(); //This is needed or setDataSource will throw IOException
m_mediaPlayer.setDataSource(con.getURL().toString());
m_mediaPlayer.prepareAsync();

@Override
public void onPrepared(MediaPlayer mp) {
    mp.start(); //Dont forget to setOnPreparedListener
}

Let me know how it went.

0

精彩评论

暂无评论...
验证码 换一张
取 消