On Tue, Nov 3, 2009 at 12:49 AM, Vladimir B <odess...@gmail.com> wrote:
> Should I use two files and swap between them while playing and downloading? > > On Nov 1, 2009 10:44 PM, "Vladimir" <odess...@gmail.com> wrote: > > Hello, all! > > I've been working on an app to stream some radio content. I get the > stream and save it to a file. When there is enough of it to play, I > invoke MediaPlayer and pass in the file. > > Here is the question...since MediaPlayer sees only the portion of the > mp3 file that has already been written when MediaPlayer was > instantiated, I have to instantiate multiple MediaPlayers and call the > seekto() method. But the reinstantiation creates a short gap in > playback -- about half a second (have been testing the app in the > emulator, but I'm guessing the same will happen on the actual phone). > > I'm sure this has been solved by others -- any suggestions??? > > Below is the thread that's called from within my Service once the > initial buffering has been done. All this does is repeatedly calling > the play() method that just reprocessing the mp3 file (while another > thread is writing to that mp3 file). > > private final Thread watchRadioPlayer = new Thread() { > public void run() { > while (isDownloading) { > curPosition = > RadioPlayer.play(OnlineRadioRetriever.fileName, > curPosition); > int delay = curPosition - previousPosition; > previousPosition = curPosition; > try { > synchronized (this) { > wait(delay); > } > } catch (InterruptedException e) { > Log.e("watchRadioPlayer", "Exception > while calling wait: ", e); > } > Log.d("watchRadioPlayer", "RUNNING for : " + > delay); > } > Log.d("watchRadioPlayer", "The THREAD is dead"); > } > }; > > -- > 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<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Thank you, Dilli Rao. M www.arijasoft.com -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.