Fix NPE on setVolume(), fade volume on next play when playback was paused by headset unplugged, improved strings, MD 0.7.6.0

This commit is contained in:
Karim Abou Zeid 2015-06-14 23:44:08 +02:00
commit 900370b1b4
3 changed files with 14 additions and 13 deletions

View file

@ -15,7 +15,6 @@ apply plugin: 'com.jakewharton.hugo'
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
} }
@ -65,6 +64,6 @@ dependencies {
compile 'de.hdodenhof:circleimageview:1.3.0' compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.afollestad:material-dialogs:0.7.5.5' compile 'com.afollestad:material-dialogs:0.7.6.0'
compile 'com.afollestad:material-cab:0.1.4' compile 'com.afollestad:material-cab:0.1.4'
} }

View file

@ -106,6 +106,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
if (intent.getAction().compareTo(AudioManager.ACTION_AUDIO_BECOMING_NOISY) == 0) { if (intent.getAction().compareTo(AudioManager.ACTION_AUDIO_BECOMING_NOISY) == 0) {
wasPlayingBeforeFocusLoss = false; wasPlayingBeforeFocusLoss = false;
pausePlaying(true); pausePlaying(true);
pausePlaying(false);
} }
} }
}; };
@ -639,7 +640,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
playerHandler.removeMessages(FADEDOWNANDPAUSE); playerHandler.removeMessages(FADEDOWNANDPAUSE);
playerHandler.sendEmptyMessage(FADEUPANDRESUME); playerHandler.sendEmptyMessage(FADEUPANDRESUME);
} else { } else {
player.setVolume(1f, 1f); if (player != null) player.setVolume(1f, 1f);
resume(); resume();
} }
} }
@ -850,7 +851,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
} else { } else {
currentDuckVolume = .2f; currentDuckVolume = .2f;
} }
service.player.setVolume(currentDuckVolume, currentDuckVolume); if (service.player != null)
service.player.setVolume(currentDuckVolume, currentDuckVolume);
break; break;
case UNDUCK: case UNDUCK:
@ -860,7 +862,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
} else { } else {
currentDuckVolume = 1.0f; currentDuckVolume = 1.0f;
} }
service.player.setVolume(currentDuckVolume, currentDuckVolume); if (service.player != null)
service.player.setVolume(currentDuckVolume, currentDuckVolume);
break; break;
case FADEDOWNANDPAUSE: case FADEDOWNANDPAUSE:
@ -877,7 +880,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
service.fadingDown = false; service.fadingDown = false;
service.pausePlaying(true); service.pausePlaying(true);
} }
service.player.setVolume(currentPlayPauseFadeVolume, currentPlayPauseFadeVolume); if (service.player != null)
service.player.setVolume(currentPlayPauseFadeVolume, currentPlayPauseFadeVolume);
break; break;
case FADEUPANDRESUME: case FADEUPANDRESUME:
@ -888,7 +892,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
} else { } else {
currentPlayPauseFadeVolume = 1.0f; currentPlayPauseFadeVolume = 1.0f;
} }
service.player.setVolume(currentPlayPauseFadeVolume, currentPlayPauseFadeVolume); if (service.player != null)
service.player.setVolume(currentPlayPauseFadeVolume, currentPlayPauseFadeVolume);
break; break;
case FOCUSCHANGE: case FOCUSCHANGE:
@ -921,9 +926,6 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
// Lost focus for a short time, but it's ok to keep playing // Lost focus for a short time, but it's ok to keep playing
// at an attenuated level // at an attenuated level
if (!service.isPlayerPrepared()) {
service.setUpMediaPlayerIfNeeded();
}
removeMessages(UNDUCK); removeMessages(UNDUCK);
sendEmptyMessage(DUCK); sendEmptyMessage(DUCK);
break; break;

View file

@ -24,10 +24,10 @@
<string name="songs">Songs</string> <string name="songs">Songs</string>
<string name="playlists">Playlists</string> <string name="playlists">Playlists</string>
<string name="nothing_playing">Nothing is playing</string> <string name="nothing_playing">Nothing is playing</string>
<string name="unplayable_file">Sorry - an error occurred while attempting to play this song.</string> <string name="unplayable_file">An error occurred while attempting to play this song.</string>
<string name="biography_unavailable">Sorry, we were not able to find a matching biography for this artist.</string> <string name="biography_unavailable">We were not able to find a matching biography for this artist.</string>
<string name="biography">Biography</string> <string name="biography">Biography</string>
<string name="audio_focus_denied">We were not able to gain audio focus.</string> <string name="audio_focus_denied">No audio focus.</string>
<string name="title_activity_tag_editor">Tag editor</string> <string name="title_activity_tag_editor">Tag editor</string>
<string name="tag_editor">Tag editor</string> <string name="tag_editor">Tag editor</string>
<string name="album">Album</string> <string name="album">Album</string>