Merge pull request #1768 from mfietz/issue/playback-speed-number-format-exception

MediaplayerActivity: Prevent NumberFormatException
This commit is contained in:
Tom Hennen 2016-03-14 17:52:09 -04:00
commit 251835bbab
1 changed files with 7 additions and 1 deletions

View File

@ -882,7 +882,13 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
private void updateButPlaybackSpeed() {
if (controller != null && butPlaybackSpeed != null) {
float speed = Float.valueOf(UserPreferences.getPlaybackSpeed());
float speed = 1.0f;
try {
speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
} catch(NumberFormatException e) {
Log.e(TAG, Log.getStackTraceString(e));
UserPreferences.setPlaybackSpeed(String.valueOf(speed));
}
String speedStr = String.format("%.2fx", speed);
butPlaybackSpeed.setText(speedStr);
}