summaryrefslogtreecommitdiff
path: root/src/plugins/android
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-05-16 16:47:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-05 11:42:16 +0200
commitcf4aba93e4c67395c53bc758138c0c16658093c3 (patch)
treea17eb2e8c950fffb7655c54c7be50ff6bba29e32 /src/plugins/android
parentcb6b4e2079d561bdb4e4e7d661c74c2f6ad15040 (diff)
downloadqtmultimedia-cf4aba93e4c67395c53bc758138c0c16658093c3.tar.gz
Android: fix media player's volume.
- Preserve the volume when changing the current media. - Don't actually set a new volume when the media player is muted. Intead, save the value to apply it when setMuted(false) is called. Change-Id: I829eb280406ea35ff82a0c2638b2d19cf1d90643 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/plugins/android')
-rw-r--r--src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java
index 01f260910..32d3496ee 100644
--- a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java
+++ b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java
@@ -248,6 +248,8 @@ public class QtAndroidMediaPlayer
if (mMediaPlayer == null) {
mMediaPlayer = new MediaPlayer();
setState(State.Idle);
+ // Make sure the new media player has the volume that was set on the QMediaPlayer
+ setVolumeHelper(mMuted ? 0 : mVolume);
}
}
@@ -477,6 +479,20 @@ public class QtAndroidMediaPlayer
public void setVolume(int volume)
{
+ if (volume < 0)
+ volume = 0;
+
+ if (volume > 100)
+ volume = 100;
+
+ mVolume = volume;
+
+ if (!mMuted)
+ setVolumeHelper(mVolume);
+ }
+
+ private void setVolumeHelper(int volume)
+ {
if ((mState & (State.Idle
| State.Initialized
| State.Stopped
@@ -487,18 +503,9 @@ public class QtAndroidMediaPlayer
return;
}
- if (volume < 0)
- volume = 0;
-
- if (volume > 100)
- volume = 100;
-
- float newVolume = adjustVolume(volume);
-
try {
+ float newVolume = adjustVolume(volume);
mMediaPlayer.setVolume(newVolume, newVolume);
- if (!mMuted)
- mVolume = volume;
} catch (final IllegalStateException e) {
Log.d(TAG, "" + e.getMessage());
}
@@ -528,7 +535,7 @@ public class QtAndroidMediaPlayer
public void mute(final boolean mute)
{
mMuted = mute;
- setVolume(mute ? 0 : mVolume);
+ setVolumeHelper(mute ? 0 : mVolume);
}
public boolean isMuted()