diff --git a/res/values/strings.xml b/res/values/strings.xml
index cfbb8aee..946884d2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,6 +16,9 @@
Disallow Use of Speaker
Do not play music when the speaker would be used
+ Pause When Unplugged
+ Pause when the headphones are unplugged.
+
Use Remote Player
Clicking the notification will open a mini-player dialog
Clicking the notification will open a the full player activity
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 533e2eb2..39798610 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -7,6 +7,11 @@
android:title="@string/headset_only_title"
android:defaultValue="false"
android:summary="@string/headset_only_summary" />
+
mSongTimeline;
private int mCurrentSong = -1;
private int mQueuePos = 0;
- private boolean mPlugged = true;
private int mState = STATE_NORMAL;
private boolean mPlayingBeforeCall;
@@ -339,13 +339,10 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
setPlaying(!mMediaPlayer.isPlaying());
break;
case HEADSET_PLUGGED:
- boolean plugged = message.arg1 == 1;
- if (plugged != mPlugged) {
- mPlugged = plugged;
- if (mCurrentSong == -1)
- return;
+ if (mHeadsetPause) {
+ boolean plugged = message.arg1 == 1;
if (!plugged && mMediaPlayer.isPlaying())
- setPlaying(false);
+ pause();
}
break;
case PREF_CHANGED:
@@ -452,6 +449,7 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
mSettings.registerOnSharedPreferenceChangeListener(this);
+ mHeadsetPause = mSettings.getBoolean("headset_pause", true);
mHeadsetOnly = mSettings.getBoolean("headset_only", false);
mUseRemotePlayer = mSettings.getBoolean("remote_player", true);
mNotifyWhilePaused = mSettings.getBoolean("notify_while_paused", true);
@@ -464,7 +462,9 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
private void loadPreference(String key)
{
- if ("headset_only".equals(key)) {
+ if ("headset_pause".equals(key)) {
+ mHeadsetPause = mSettings.getBoolean("headset_pause", true);
+ } else if ("headset_only".equals(key)) {
mHeadsetOnly = mSettings.getBoolean(key, false);
if (mHeadsetOnly && isSpeakerOn() && mMediaPlayer.isPlaying())
pause();