Re: [android-developers] Re: Using MediaPlayer best practices?
You can register the buffering listener and save the current buffering position. You can also poll for current position say every second (using your ui handler), and if current position did not change since last poll, show ui message (or dialog). Alexey Krasnoriadtsev Agile Fusion Corp On Wed, Nov 4, 2009 at 9:23 AM, Moto wrote: > Thanks Alex! > > When you say peek at the MediaPlaybackService you mean android > framework code? > > I was afraid that MediaPlayer would somehow end in an invalid state if > the internal server died or something but I guess reset() cleans it > up... As of now I just use Reset() to stop playback.. :P seems to be > faster than Stop() plus it cleans the MediaPlayer to be ready for > another SetDataSource() and Prepare()... > > Something I don't like about MediaPlayer is that you can't get the > audio status! Say it's progressively playing a file from the internet > and all the sudden audio stops because it doesn't have enough > data... I want to know when that happens and there is no information > for that... Any ideas on this part? > > Thanks, > -Moto > > On Nov 4, 3:34 am, Alexey Krasnoriadtsev > wrote: > > Preparing a mediaPlayer is the most expensive operation. > > calling stop() or pause() and then start() works best for me. You can > > also peek at the MediaPlaybackService for inspiration. > > > > Why do you think it will get into the bad state? > > > > On Nov 3, 7:14 pm, Moto wrote: > > > > > What is the best way to use the MediaPlayer when needed multiple > > > times? > > > > > Reuse the instantiated MediaPlayer throughout the session? Or > > > constantly stop() release() and instantiate a new MediaPlayer() ? > > > > > If I reuse I'm afraid the player could be in a bad state? > > > What about performance wise? what's better? reuse or renew? > > > > > Note: This is for using as a music player so one audio be present at > > > one given time... > > > > > Thank! > > > -Moto! > > -- > 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 > -- 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: Using MediaPlayer best practices?
Thanks Alex! When you say peek at the MediaPlaybackService you mean android framework code? I was afraid that MediaPlayer would somehow end in an invalid state if the internal server died or something but I guess reset() cleans it up... As of now I just use Reset() to stop playback.. :P seems to be faster than Stop() plus it cleans the MediaPlayer to be ready for another SetDataSource() and Prepare()... Something I don't like about MediaPlayer is that you can't get the audio status! Say it's progressively playing a file from the internet and all the sudden audio stops because it doesn't have enough data... I want to know when that happens and there is no information for that... Any ideas on this part? Thanks, -Moto On Nov 4, 3:34 am, Alexey Krasnoriadtsev wrote: > Preparing a mediaPlayer is the most expensive operation. > calling stop() or pause() and then start() works best for me. You can > also peek at the MediaPlaybackService for inspiration. > > Why do you think it will get into the bad state? > > On Nov 3, 7:14 pm, Moto wrote: > > > What is the best way to use the MediaPlayer when needed multiple > > times? > > > Reuse the instantiated MediaPlayer throughout the session? Or > > constantly stop() release() and instantiate a new MediaPlayer() ? > > > If I reuse I'm afraid the player could be in a bad state? > > What about performance wise? what's better? reuse or renew? > > > Note: This is for using as a music player so one audio be present at > > one given time... > > > Thank! > > -Moto! -- 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: Using MediaPlayer best practices?
Preparing a mediaPlayer is the most expensive operation. calling stop() or pause() and then start() works best for me. You can also peek at the MediaPlaybackService for inspiration. Why do you think it will get into the bad state? On Nov 3, 7:14 pm, Moto wrote: > What is the best way to use the MediaPlayer when needed multiple > times? > > Reuse the instantiated MediaPlayer throughout the session? Or > constantly stop() release() and instantiate a new MediaPlayer() ? > > If I reuse I'm afraid the player could be in a bad state? > What about performance wise? what's better? reuse or renew? > > Note: This is for using as a music player so one audio be present at > one given time... > > Thank! > -Moto! -- 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