summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java27
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java33
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java8
-rw-r--r--core/src/main/res/drawable/ic_fab_edit_black.xml5
-rw-r--r--core/src/main/res/drawable/ic_fab_edit_white.xml (renamed from core/src/main/res/drawable/ic_fab_edit.xml)0
-rw-r--r--core/src/main/res/values/attrs.xml1
-rw-r--r--core/src/main/res/values/strings.xml2
-rw-r--r--core/src/main/res/values/styles.xml24
11 files changed, 70 insertions, 50 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 4cc1a9c32..b8ab1c888 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -109,6 +109,7 @@ public class UserPreferences {
public static final String PREF_MEDIA_PLAYER = "prefMediaPlayer";
public static final String PREF_MEDIA_PLAYER_EXOPLAYER = "exoplayer";
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
+ private static final String PREF_VIDEO_PLAYBACK_SPEED = "prefVideoPlaybackSpeed";
public static final String PREF_PLAYBACK_SKIP_SILENCE = "prefSkipSilence";
private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs";
private static final String PREF_REWIND_SECS = "prefRewindSecs";
@@ -319,8 +320,24 @@ public class UserPreferences {
return prefs.getBoolean(PREF_DELETE_REMOVES_FROM_QUEUE, false);
}
- public static String getPlaybackSpeed() {
- return prefs.getString(PREF_PLAYBACK_SPEED, "1.00");
+ public static float getPlaybackSpeed() {
+ try {
+ return Float.parseFloat(prefs.getString(PREF_PLAYBACK_SPEED, "1.00"));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, Log.getStackTraceString(e));
+ UserPreferences.setPlaybackSpeed("1.00");
+ return 1.0f;
+ }
+ }
+
+ public static float getVideoPlaybackSpeed() {
+ try {
+ return Float.parseFloat(prefs.getString(PREF_VIDEO_PLAYBACK_SPEED, "1.00"));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, Log.getStackTraceString(e));
+ UserPreferences.setVideoPlaybackSpeed("1.00");
+ return 1.0f;
+ }
}
public static boolean isSkipSilence() {
@@ -559,6 +576,12 @@ public class UserPreferences {
.apply();
}
+ public static void setVideoPlaybackSpeed(String speed) {
+ prefs.edit()
+ .putString(PREF_VIDEO_PLAYBACK_SPEED, speed)
+ .apply();
+ }
+
public static void setSkipSilence(boolean skipSilence) {
prefs.edit()
.putBoolean(PREF_PLAYBACK_SKIP_SILENCE, skipSilence)
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
index b26d3011d..7938e262d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
@@ -213,8 +213,9 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
private String getProgressString(int position, int duration) {
if (position > 0 && duration > 0) {
- position = TimeSpeedConverter.convert(position);
- duration = TimeSpeedConverter.convert(duration);
+ TimeSpeedConverter converter = new TimeSpeedConverter(playbackService.getCurrentPlaybackSpeed());
+ position = converter.convert(position);
+ duration = converter.convert(duration);
return Converter.getDurationStringLong(position) + " / "
+ Converter.getDurationStringLong(duration);
} else {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
index 9a8353806..6bd736de7 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
@@ -303,14 +303,11 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
Log.d(TAG, "Audiofocus successfully requested");
Log.d(TAG, "Resuming/Starting playback");
acquireWifiLockIfNecessary();
- float speed = 1.0f;
- try {
- speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
- } catch(NumberFormatException e) {
- Log.e(TAG, Log.getStackTraceString(e));
- UserPreferences.setPlaybackSpeed(String.valueOf(speed));
+ if (media.getMediaType() == MediaType.VIDEO) {
+ setPlaybackParams(UserPreferences.getVideoPlaybackSpeed(), UserPreferences.isSkipSilence());
+ } else {
+ setPlaybackParams(UserPreferences.getPlaybackSpeed(), UserPreferences.isSkipSilence());
}
- setPlaybackParams(speed, UserPreferences.isSkipSilence());
setVolume(UserPreferences.getLeftVolume(), UserPreferences.getRightVolume());
if (playerStatus == PlayerStatus.PREPARED && media.getPosition() > 0) {
@@ -601,11 +598,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
*/
@Override
public boolean canSetSpeed() {
- boolean retVal = false;
- if (mediaPlayer != null && media != null && media.getMediaType() == MediaType.AUDIO) {
- retVal = (mediaPlayer).canSetSpeed();
- }
- return retVal;
+ return mediaPlayer != null && mediaPlayer.canSetSpeed();
}
/**
@@ -614,13 +607,11 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
*/
private void setSpeedSyncAndSkipSilence(float speed, boolean skipSilence) {
playerLock.lock();
- if (media != null && media.getMediaType() == MediaType.AUDIO) {
- if (mediaPlayer.canSetSpeed()) {
- Log.d(TAG, "Playback speed was set to " + speed);
- callback.playbackSpeedChanged(speed);
- }
- mediaPlayer.setPlaybackParams(speed, skipSilence);
+ if (mediaPlayer.canSetSpeed()) {
+ Log.d(TAG, "Playback speed was set to " + speed);
+ callback.playbackSpeedChanged(speed);
}
+ mediaPlayer.setPlaybackParams(speed, skipSilence);
playerLock.unlock();
}
@@ -667,10 +658,8 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
*/
private void setVolumeSync(float volumeLeft, float volumeRight) {
playerLock.lock();
- if (media != null && media.getMediaType() == MediaType.AUDIO) {
- mediaPlayer.setVolume(volumeLeft, volumeRight);
- Log.d(TAG, "Media player volume was set to " + volumeLeft + " " + volumeRight);
- }
+ mediaPlayer.setVolume(volumeLeft, volumeRight);
+ Log.d(TAG, "Media player volume was set to " + volumeLeft + " " + volumeRight);
playerLock.unlock();
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java
index 5fea8238b..5d44c14b8 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java
@@ -3,18 +3,19 @@ package de.danoeh.antennapod.core.util;
import de.danoeh.antennapod.core.preferences.UserPreferences;
public class TimeSpeedConverter {
- private TimeSpeedConverter() {
+ private final float speed;
+ public TimeSpeedConverter(float speed) {
+ this.speed = speed;
}
/** Convert millisecond according to the current playback speed
* @param time: time to convert
* @return converted time (can be < 0 if time is < 0)
*/
- public static int convert(int time) {
+ public int convert(int time) {
boolean timeRespectsSpeed = UserPreferences.timeRespectsSpeed();
if (time > 0 && timeRespectsSpeed) {
- float speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
return (int)(time / speed);
}
return time;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java
index b04c02075..32d37a67e 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java
@@ -16,10 +16,16 @@ public class MediaPlayerError {
case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
resId = R.string.playback_error_server_died;
break;
+ case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
+ resId = R.string.playback_error_unsupported;
+ break;
+ case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
+ resId = R.string.playback_error_timeout;
+ break;
default:
resId = R.string.playback_error_unknown;
break;
}
- return context.getString(resId);
+ return context.getString(resId) + " (" + code + ")";
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
index 5b2d7b13e..0cfaaab3c 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
@@ -54,7 +54,7 @@ import org.greenrobot.eventbus.ThreadMode;
* Communicates with the playback service. GUI classes should use this class to
* control playback instead of communicating with the PlaybackService directly.
*/
-public abstract class PlaybackController {
+public class PlaybackController {
private static final String TAG = "PlaybackController";
@@ -567,7 +567,8 @@ public abstract class PlaybackController {
if (fromUser && playbackService != null && media != null) {
float prog = progress / ((float) seekBar.getMax());
int duration = media.getDuration();
- int position = TimeSpeedConverter.convert((int) (prog * duration));
+ TimeSpeedConverter converter = new TimeSpeedConverter(playbackService.getCurrentPlaybackSpeed());
+ int position = converter.convert((int) (prog * duration));
txtvPosition.setText(Converter.getDurationStringLong(position));
return prog;
}
@@ -719,6 +720,7 @@ public abstract class PlaybackController {
public boolean canSetPlaybackSpeed() {
return org.antennapod.audio.MediaPlayer.isPrestoLibraryInstalled(activity.getApplicationContext())
|| UserPreferences.useSonic()
+ || UserPreferences.useExoplayer()
|| Build.VERSION.SDK_INT >= 23
|| (playbackService != null && playbackService.canSetSpeed());
}
@@ -741,7 +743,7 @@ public abstract class PlaybackController {
}
public float getCurrentPlaybackSpeedMultiplier() {
- if (canSetPlaybackSpeed()) {
+ if (playbackService != null && canSetPlaybackSpeed()) {
return playbackService.getCurrentPlaybackSpeed();
} else {
return -1;
diff --git a/core/src/main/res/drawable/ic_fab_edit_black.xml b/core/src/main/res/drawable/ic_fab_edit_black.xml
new file mode 100644
index 000000000..a9fec7080
--- /dev/null
+++ b/core/src/main/res/drawable/ic_fab_edit_black.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FF000000" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
+</vector>
diff --git a/core/src/main/res/drawable/ic_fab_edit.xml b/core/src/main/res/drawable/ic_fab_edit_white.xml
index cb2e394b0..cb2e394b0 100644
--- a/core/src/main/res/drawable/ic_fab_edit.xml
+++ b/core/src/main/res/drawable/ic_fab_edit_white.xml
diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml
index eb7f065ce..5b0bf5717 100644
--- a/core/src/main/res/values/attrs.xml
+++ b/core/src/main/res/values/attrs.xml
@@ -74,4 +74,5 @@
<attr name="about_screen_card_background" format="color"/>
<attr name="about_screen_card_border" format="color"/>
<attr name="about_screen_font_color" format="color"/>
+ <attr name="batch_edit_fab_icon" format="reference"/>
</resources>
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 065f9f50e..8ab3a9c15 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -277,6 +277,8 @@
<string name="player_ready_msg">Ready</string>
<string name="player_seeking_msg">Seeking</string>
<string name="playback_error_server_died">Server died</string>
+ <string name="playback_error_unsupported">Unsupported media type</string>
+ <string name="playback_error_timeout">Operation timed out</string>
<string name="playback_error_unknown">Unknown Error</string>
<string name="no_media_playing_label">No media playing</string>
<string name="position_default_label" translate="false">00:00:00</string>
diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml
index 4c69306a9..fb69e54e7 100644
--- a/core/src/main/res/values/styles.xml
+++ b/core/src/main/res/values/styles.xml
@@ -72,6 +72,7 @@
<item name="ic_bug">@drawable/ic_bug_grey600_24dp</item>
<item name="ic_known_issues">@drawable/ic_format_list_bulleted_grey600_24dp</item>
<item name="ic_bookmark">@drawable/ic_bookmark_grey600_24dp</item>
+ <item name="batch_edit_fab_icon">@drawable/ic_fab_edit_white</item>
<item name="master_switch_background">@color/master_switch_background_light</item>
<item name="currently_playing_background">@color/highlight_light</item>
@@ -156,6 +157,7 @@
<item name="ic_bug">@drawable/ic_bug_white_24dp</item>
<item name="ic_known_issues">@drawable/ic_format_list_bulleted_white_24dp</item>
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
+ <item name="batch_edit_fab_icon">@drawable/ic_fab_edit_white</item>
<item name="master_switch_background">@color/master_switch_background_dark</item>
<item name="currently_playing_background">@color/highlight_dark</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
@@ -176,6 +178,7 @@
<item name="overlay_background">@color/black</item>
<item name="overlay_drawable">@drawable/overlay_drawable_dark_trueblack</item>
<item name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
+ <item name="batch_edit_fab_icon">@drawable/ic_fab_edit_black</item>
<item name="dragview_float_background">@color/black</item>
<item name="nav_drawer_background">@color/black</item>
<item name="drawer_activated_color">@color/highlight_trueblack</item>
@@ -213,23 +216,10 @@
<!-- Room for API dependent attributes -->
</style>
- <style name="Theme.Base.AntennaPod.TrueBlack.NoTitle" parent="Theme.Base.AntennaPod.Dark.NoTitle">
- <item name="progressBarTheme">@style/ProgressBarTrueBlack</item>
- <item name="non_transparent_background">@color/black</item>
- <item name="overlay_background">@color/black</item>
- <item name="overlay_drawable">@drawable/overlay_drawable_dark_trueblack</item>
- <item name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
- <item name="dragview_float_background">@color/black</item>
- <item name="nav_drawer_background">@color/black</item>
- <item name="drawer_activated_color">@color/highlight_trueblack</item>
- <item name="currently_playing_background">@color/highlight_trueblack</item>
- <item name="android:textColorPrimary">@color/white</item>
- <item name="android:color">@color/white</item>
- <item name="android:colorBackground">@color/black</item>
- <item name="android:windowBackground">@color/black</item>
- <item name="android:actionBarStyle">@color/black</item>
- <item name="colorPrimary">@color/black</item>
- <item name="colorPrimaryDark">@color/black</item>
+ <style name="Theme.Base.AntennaPod.TrueBlack.NoTitle" parent="Theme.Base.AntennaPod.TrueBlack">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="windowActionModeOverlay">true</item>
</style>