No problem playing an MP3 from the SD card. You should be able to ACTION_VIEW the file:/// URI directly, or invoke the media scanner on it and ACTION_VIEW the resulting content:// URI (added bonus for the second method is that the file will immediately show up in the music player as well).
JBQ On Tue, Mar 31, 2009 at 7:08 AM, Streets Of Boston <[email protected]> wrote: > > This is just copying the file. > The question remains if you can play it or not... :=) > > I have not looked into this at all, but DRM could prevent the mp3 from > playing. > > On Mar 31, 9:55 am, iDeveloper <[email protected]> wrote: >> Thanks a ton. Didn't know android allowed saving to mp3 directly >> unlike an iphone. >> >> On 31-Mar-09, at 5:32 PM, MrChaz wrote: >> >> >> >> >> >> > Sure, >> > Something like >> >> > //Where the file comes from >> > URL sourceURL = new URL("address"); >> > URLConnection conn = sourceURL.openConnection(); >> >> > InputStream inStream = sourceURL.openStream(); >> >> > // Where the file is going to go >> > FileOutputStream outStream= new FileOutputStream("sdcard/file.mp3"); >> >> > //a read buffer >> > byte[] bytes = new byte[20480]; >> >> > //read the first chunk >> > int readBytes = file.read(bytes); >> >> > //read the rest >> > while (readBytes > 0){ >> > //Write the buffered chunk to the file >> > outStream.write(bytes, 0, readBytes); >> > readBytes = file.read(bytes); >> > } >> > inStream.close(); >> > outStream.close(); >> >> > should do it. I've typed that more or less by hand so it's missing >> > error checking etc. >> >> > On Mar 31, 8:10 am, idev <[email protected]> wrote: >> >> Hi >> >> >> I am able to stream an mp3 at real time on my android phone. I wanted >> >> to know if it is possible to save an mp3 file residing on a remote >> >> location to my SD card. >> >> >> Any heads up is greatly appreciated. >> >> >> Thanks.- Hide quoted text - >> >> - Show quoted text - > > > -- Jean-Baptiste M. "JBQ" Queru Android Engineer, Google. Questions sent directly to me that have no reason for being private will likely get ignored or forwarded to a public forum with no further warning. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

