Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent for HTTP MP3 stream on HTC Incredible

On the stock Droid and Nexus One, an intent like this:

new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.parse("http://example.com/somemp3.mp3"), "audio/mp3");

works just fine and pops open the system music player to stream the file. But it doesn't match any activities on the HTC Incredible, causing a force-close when I call startActivity on it (I'm guessing due to missing intent filters in SenseUI's replacement applications). I'd prefer not to have to manage a MediaPlayer instance myself if I don't have to; does anyone know if there's a way to structure an Intent to convince the Incredible to play an MP3 stream over HTTP in its built-in Music or Streaming Media apps?

like image 630
Yoni Samlan Avatar asked May 19 '10 20:05

Yoni Samlan


2 Answers

Try "audio/*" type. I think it works.

like image 113
Fedor Avatar answered Sep 22 '22 14:09

Fedor


This code worked for me:

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(url), "audio/*");
context.startActivity(i);

You can also view video streaming, using "video/*" type.

This method worked on both Android 1.5 and 2.2, not sure about SenseUI compatibility. "audio/mp3" didn't work for me either, so it's not senseUI specific.

like image 22
NoBugs Avatar answered Sep 21 '22 14:09

NoBugs