1 Replies - 916 Views - Last Post: 01 October 2012 - 11:26 PM

#1 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

MediaPlayer.SeekTo(int) throws IllegalStateException

Posted 01 October 2012 - 12:25 PM

Hi.
The title says it all. sometimes i get IllegalStateException thrown by MediaPlayer.SeekTo(int)
The MediaPlayer runs in a Service, and a call the SeekTo(int) like this:
	public void seekTo(int value){
		if (mp != null && !(value <= -1)) {
		mp.seekTo(value);
		}
	}

I've googled it, but can't find any answer.


Thanks in advance
Is This A Good Question/Topic? 0
  • +

Replies To: MediaPlayer.SeekTo(int) throws IllegalStateException

#2 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: MediaPlayer.SeekTo(int) throws IllegalStateException

Posted 01 October 2012 - 11:26 PM

Found the problem. The method was called while the MediaPlayer was running the Prepare(); method.
Just added Private boolean isPrepared = false;
Then in the OnPrepared i simply added isPrepared = true, and isPrepared = false when i call the Prepare(); method.
So now i can just check if it's prepared and then do the SeekTo(int);
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1