[android-developers] Re: How can I implement AB repeat function using mediaplayer

2012-04-19 Thread SH
Thanks, Chris.

After researching, I implemented the function by myself using tracking
the repeat mode.

Thread repeatThread = new Thread(){
public void run(){
   while (mediaPlayer!=null) {
if (isRepeatMode() &&
mediaPlayer.getCurrentPosition()>=toPoint) {
  mediaPlayer.seekTo(fromPoint);
}

//Code delaying 1second here...

   }
}
}

I started this thread just after the mediaplayer prepared in the event
listener. I think that there is better way to do that, but it works
well.

On Apr 20, 5:05 am, Chris Stratton  wrote:
> On Wednesday, April 18, 2012 10:46:21 PM UTC-4, SH wrote:
>
> > Hi all.
>
> > I try to develop an audio player and would like to have A-B repeat
> > function. When a user click A button while playing, it memorise
> > starting position and clicking B button, it will save ending position.
> > So it repeat A to B points until the user clear repeat position.
> > It is easy to go back to the starting position B but not easy for
> > endping position B because there is not listener to track when it
> > arrived to the marked point.
> > I look forward to your idea.
> > Thanks in advance.
>
> It's been a couple months since I was working on something similar, but
> your options would likely be something along the lines of either
> piggybacking off of the progress bar updates (if possible) or using a
> thread to poll the position of the player.  When either of those methods
> indicates you are at or past your end point, seek to the desired start
> point again.
>
> Unfortunately, I'm not aware of a "play until" interface.

-- 
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: How can I implement AB repeat function using mediaplayer

2012-04-19 Thread Chris Stratton
On Wednesday, April 18, 2012 10:46:21 PM UTC-4, SH wrote:
>
> Hi all. 
>
> I try to develop an audio player and would like to have A-B repeat 
> function. When a user click A button while playing, it memorise 
> starting position and clicking B button, it will save ending position. 
> So it repeat A to B points until the user clear repeat position. 
> It is easy to go back to the starting position B but not easy for 
> endping position B because there is not listener to track when it 
> arrived to the marked point. 
> I look forward to your idea. 
> Thanks in advance.


It's been a couple months since I was working on something similar, but 
your options would likely be something along the lines of either 
piggybacking off of the progress bar updates (if possible) or using a 
thread to poll the position of the player.  When either of those methods 
indicates you are at or past your end point, seek to the desired start 
point again.  

Unfortunately, I'm not aware of a "play until" interface.

 

-- 
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