From 6d605c1cbf8eb5f43543d819afec77a04abe6ec2 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Thu, 14 Oct 2010 09:58:37 -0500 Subject: [PATCH] Set prepareListener before calling prepare. --- framework/src/com/phonegap/AudioPlayer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/com/phonegap/AudioPlayer.java b/framework/src/com/phonegap/AudioPlayer.java index 48a58004..44c71776 100755 --- a/framework/src/com/phonegap/AudioPlayer.java +++ b/framework/src/com/phonegap/AudioPlayer.java @@ -182,6 +182,8 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On if (this.isStreaming(file)) { this.mPlayer.setDataSource(file); this.mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + this.setState(MEDIA_STARTING); + this.mPlayer.setOnPreparedListener(this); this.mPlayer.prepareAsync(); } @@ -195,13 +197,13 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On else { this.mPlayer.setDataSource("/sdcard/" + file); } + this.setState(MEDIA_STARTING); + this.mPlayer.setOnPreparedListener(this); this.mPlayer.prepare(); // Get duration this.duration = this.mPlayer.getDuration(); } - this.mPlayer.setOnPreparedListener(this); - this.setState(MEDIA_STARTING); } catch (Exception e) { e.printStackTrace();