[android-developers] Re: More MediaPlayer questions
HI, Can anyone of you know how to extract the comosers info from Mp3 file. Please let me know if you know that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
Don't hijack the post create your own. On 12/18/2008, Rajendrakumar C rajendran.b...@gmail.com wrote: HI, Can anyone of you know how to extract the comosers info from Mp3 file. Please let me know if you know that. -- Xavier A. Mathews Student/Browser Specialist/Developer/Web-Master Client Based Tech Support Specialist Hazel Crest Illinois xavieruni...@gmail.com¥xavierunited@hotmail.com¥truestar...@yahoo.com Fear of a name, only increases fear of the thing itself. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
Hii Greg, How to create a url to raw via android:resource://package/raw/name as you have said? as setDataSource(url) is not working i copied a file to local path and tried passing that path to setDataSource(path),even that gives error Please tell me how to copy file directly to raw from url. This is very urgent for me. Thanks Kavitha On Dec 10, 6:01 pm, Greg gregory.r.fie...@gmail.com wrote: I've been googling and searching the groups for answers and haven't been able to find anything concrete. I have several questions regarding the use of MediaPlayer if somebody can help me out: 1. I need to package an audio resource with my application, which I have done in /res/raw. However, it appears that I must use MediaPlayer.create() to use a resource ID rather than MediaPlayer.setDataSource(). I found some references to creating a URI to raw via android:resource://package/raw/name and android:resource//package/ + resourceId. However, both of these tries resulted in IOExceptions during setDataSource. I'm assuming due to a bad URI. Is it possible to get a valid URI in SDK 1.0 that will point to a raw resource? 2. I'm writing an app that does some tracking and will typically go hand in hand with the music player running. Part of my app will, at times, need to play sound on top of the running audio stream. Is there any way for my app to get ahold of and temporarily pause the music stream so that the user will be able to clearly hear my audio? Is this prevented because it's considered 'bad behavior'? (I hope not because in my case its actually good and desirable behavior) 3. I see that I can set the audio stream but is there any documentation/discussion/details on what the various streams are, how they are used, and how they interact with one another? For example, as mentioned above I want to be able to pause/override/interrupt a music playing stream with my notification but I would NOT want to have my notification play if they are on an active phone call. Also, is there any doc/discussion/detail on which methods can be invoked on the mediaplayer at what times? As I experiment I seem to get a lot of 'invalid media state' errors when I try things with very little indication as to what state it is in and how I get it from the bad state to an acceptable state for the method in question. Thanks for any assistance. I've been researching for a couple of days but all the information I can find is very sparse or appears to be things that were valid in early SDKs but may not be any longer. Thanks, Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
The media server does not have access to your application's data directory for security reasons. If you want the media server to play a file in your data directory, you need to open the file in your app and use the setDataSource(fd) method to pass open file descriptor to media player. Alternatively, you can copy the data files to the SD card and play by path. On Dec 16, 10:59 pm, kavith...@gmail.com kavithachitr...@gmail.com wrote: Hii Greg, How to create a url to raw via android:resource://package/raw/name as you have said? as setDataSource(url) is not working i copied a file to local path and tried passing that path to setDataSource(path),even that gives error Please tell me how to copy file directly to raw from url. This is very urgent for me. Thanks Kavitha On Dec 10, 6:01 pm, Greg gregory.r.fie...@gmail.com wrote: I've been googling and searching the groups for answers and haven't been able to find anything concrete. I have several questions regarding the use of MediaPlayer if somebody can help me out: 1. I need to package an audio resource with my application, which I have done in /res/raw. However, it appears that I must use MediaPlayer.create() to use a resource ID rather than MediaPlayer.setDataSource(). I found some references to creating a URI to raw via android:resource://package/raw/name and android:resource//package/ + resourceId. However, both of these tries resulted in IOExceptions during setDataSource. I'm assuming due to a bad URI. Is it possible to get a valid URI in SDK 1.0 that will point to a raw resource? 2. I'm writing an app that does some tracking and will typically go hand in hand with the music player running. Part of my app will, at times, need to play sound on top of the running audio stream. Is there any way for my app to get ahold of and temporarily pause the music stream so that the user will be able to clearly hear my audio? Is this prevented because it's considered 'bad behavior'? (I hope not because in my case its actually good and desirable behavior) 3. I see that I can set the audio stream but is there any documentation/discussion/details on what the various streams are, how they are used, and how they interact with one another? For example, as mentioned above I want to be able to pause/override/interrupt a music playing stream with my notification but I would NOT want to have my notification play if they are on an active phone call. Also, is there any doc/discussion/detail on which methods can be invoked on the mediaplayer at what times? As I experiment I seem to get a lot of 'invalid media state' errors when I try things with very little indication as to what state it is in and how I get it from the bad state to an acceptable state for the method in question. Thanks for any assistance. I've been researching for a couple of days but all the information I can find is very sparse or appears to be things that were valid in early SDKs but may not be any longer. Thanks, Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
Thanks for the info Dave (especially getting call for the raw file descriptor!). Allow me to help you grok the fullness of this (wonder how many people have actually read that book these days) :) My app actually runs in foreground and background (via service) for doing some exercise tracking. As someone is out moving about they may start my app, set things up, and start tracking then leave the app. The service is in background paying attention to what its supposed to (GPS, calculations, etc.) and at certain intervals needs to 'read out' some statistics. I don't want to build my own mp3 player in the app because it's a) not what I want to focus on and b) not going to be as good as everything else that is already out there. I would much prefer to just play nicely with existing mp3 apps. The only requirement I would have is this one ability to either play my notification over the audio stream louder than the music or (preferably) suspend/pause the music stream to play my notification, then resume the other streams. The phone could be in one of several states: 1. MP3 player playing, my app in foreground, my app service running. 2. MP3 player in foreground, my app gone, my app service running. 3. Some other app in foreground (on a call maybe), my app gone, my app service running. Again what I'm looking for here is the best way for my notifications to interrupt any current audio stream (except a phone call) that is going on as long as my service is active. (If my service is active in background, then the user wants to hear these notifications) Do the audio stream types interact/override one another? If I put my player in the ALARM type will that stop/play louder than the MUSIC type? Thanks! Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com 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 -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
I'm beginning to grok the fullness... :) You could use the ALARM stream, though the user might have silenced alarms and then nothing will be heard. We are adding the ability to send events to the music player to tell it to play, pause, skip, etc. to support AVRCP. This will come in a release in Q1. That seems like the ideal way to hook your app in, and hopefully 3rd party music player apps will pick up on this as well. On Dec 11, 7:13 am, Greg gregory.r.fie...@gmail.com wrote: Thanks for the info Dave (especially getting call for the raw file descriptor!). Allow me to help you grok the fullness of this (wonder how many people have actually read that book these days) :) My app actually runs in foreground and background (via service) for doing some exercise tracking. As someone is out moving about they may start my app, set things up, and start tracking then leave the app. The service is in background paying attention to what its supposed to (GPS, calculations, etc.) and at certain intervals needs to 'read out' some statistics. I don't want to build my own mp3 player in the app because it's a) not what I want to focus on and b) not going to be as good as everything else that is already out there. I would much prefer to just play nicely with existing mp3 apps. The only requirement I would have is this one ability to either play my notification over the audio stream louder than the music or (preferably) suspend/pause the music stream to play my notification, then resume the other streams. The phone could be in one of several states: 1. MP3 player playing, my app in foreground, my app service running. 2. MP3 player in foreground, my app gone, my app service running. 3. Some other app in foreground (on a call maybe), my app gone, my app service running. Again what I'm looking for here is the best way for my notifications to interrupt any current audio stream (except a phone call) that is going on as long as my service is active. (If my service is active in background, then the user wants to hear these notifications) Do the audio stream types interact/override one another? If I put my player in the ALARM type will that stop/play louder than the MUSIC type? Thanks! Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: More MediaPlayer questions
You want some code like this to play from raw resources: AssetFileDescriptor afd = getResources().openRawResourceFd (R.raw.test); if (afd != null) { mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); } else { throw new IOException(Unable to open test file); } I don't quite grok what you want to do with the music player. Is your app in the foreground while the music player is in the background? If so and you aren't using any elements of the music player UI, why not just create your own music player inside the app that you can control? There is a headset button interface you might be able to inject events into to get the music player to pause and resume if you have to go that way to get the UI. It's not going to give you very fine-grained control over timing. If the user is on a call, your application does not have focus and you should not be doing anything. That said, the user could bring your app to the fore while on the call and start playing with it. My view on that is to let them do it, so we allow users to pull up YouTube or the music player and use them while still on the call. There is an API to detect if the ringtone is playing or the user is on a call - I believe it's in android.media.AudioService, but I could be wrong. We're working on improved docs for the media framework. Generally, there's a pretty strict regiment you have to follow to get from a new MediaPlayer object to the playing state: MediaPlayer m = new MediaPlayer(); m.setDataSource(uri); m.setAudioStreamType(streamType); m.prepare(); // or prepareAsync() and wait for OnPrepared to fire // setDataSource and setAudioStreamType are no longered allowed unless after reset() // getDuration, getCurrentPosition, setLooping, setVolume, isPlaying are all valid now m.start(); // now you can also pause, start, seekTo (paused or playing), and stop. reset() is valid in any state, though we have a bug in RC30 if you haven't take a media player to prepare state, the app thread will deadlock in reset(). Will be fixed in a release soon. Hope this helps. On Dec 10, 6:01 pm, Greg [EMAIL PROTECTED] wrote: I've been googling and searching the groups for answers and haven't been able to find anything concrete. I have several questions regarding the use of MediaPlayer if somebody can help me out: 1. I need to package an audio resource with my application, which I have done in /res/raw. However, it appears that I must use MediaPlayer.create() to use a resource ID rather than MediaPlayer.setDataSource(). I found some references to creating a URI to raw via android:resource://package/raw/name and android:resource//package/ + resourceId. However, both of these tries resulted in IOExceptions during setDataSource. I'm assuming due to a bad URI. Is it possible to get a valid URI in SDK 1.0 that will point to a raw resource? 2. I'm writing an app that does some tracking and will typically go hand in hand with the music player running. Part of my app will, at times, need to play sound on top of the running audio stream. Is there any way for my app to get ahold of and temporarily pause the music stream so that the user will be able to clearly hear my audio? Is this prevented because it's considered 'bad behavior'? (I hope not because in my case its actually good and desirable behavior) 3. I see that I can set the audio stream but is there any documentation/discussion/details on what the various streams are, how they are used, and how they interact with one another? For example, as mentioned above I want to be able to pause/override/interrupt a music playing stream with my notification but I would NOT want to have my notification play if they are on an active phone call. Also, is there any doc/discussion/detail on which methods can be invoked on the mediaplayer at what times? As I experiment I seem to get a lot of 'invalid media state' errors when I try things with very little indication as to what state it is in and how I get it from the bad state to an acceptable state for the method in question. Thanks for any assistance. I've been researching for a couple of days but all the information I can find is very sparse or appears to be things that were valid in early SDKs but may not be any longer. Thanks, Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com 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 -~--~~~~--~~--~--~---