summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/arrays.xml15
-rw-r--r--res/values/strings.xml10
-rw-r--r--res/xml/preferences.xml4
-rw-r--r--src/de/danoeh/antennapod/activity/PreferenceActivity.java46
-rw-r--r--src/de/danoeh/antennapod/dialog/GetSpeedPlaybackPlugin.java31
-rw-r--r--src/de/danoeh/antennapod/preferences/UserPreferences.java25
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java18
7 files changed, 144 insertions, 5 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index b8cef4ab2..9881ae2bd 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -41,6 +41,20 @@
<item>100</item>
</string-array>
+ <string-array name="playback_speed_values">
+ <item>1.0</item>
+ <item>1.10</item>
+ <item>1.20</item>
+ <item>1.30</item>
+ <item>1.40</item>
+ <item>1.50</item>
+ <item>1.60</item>
+ <item>1.70</item>
+ <item>1.80</item>
+ <item>1.90</item>
+ <item>2.0</item>
+ </string-array>
+
<string-array name="autodl_select_networks_default_entries">
<item>N/A</item>
</string-array>
@@ -58,5 +72,6 @@
<item>0</item>
<item>1</item>
</string-array>
+
</resources> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 54438b9cc..21ddf829b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -44,6 +44,8 @@
<string name="processing_label">Processing</string>
<string name="loading_label">Loading...</string>
<string name="image_of_prefix">Image of:\u0020</string>
+ <string name="close_label">Close</string>
+
<!-- 'Add Feed' Activity labels -->
<string name="feedurl_label">Feed URL</string>
@@ -140,6 +142,12 @@
<string name="access_revoked_info">You have successfully revoked AntennaPod\'s access token to your account. In order to complete the process, you have to remove this app from the list of approved applications in your account settings on the flattr website.</string>
<string name="flattr_click_success">Successfully flattred this thing!</string>
<string name="flattring_label">Flattring</string>
+
+ <!-- Variable Speed -->
+ <string name="download_plugin_label">Download Plugin</string>
+ <string name="no_playback_plugin_title">Plugin Not Installed</string>
+ <string name="no_playback_plugin_msg">For variable speed playback to work, a third party library must be installed.\n\nTap \'Download Plugin\' to download a free plugin from the Play Store\n\nAny problems found using this plugin are not the responsibility of AntennaPod and should be reported to the plugin owner.</string>
+ <string name="set_playback_speed_label">Playback Speed</string>
<!-- Empty list labels -->
<string name="no_items_label">There are no items in this list.</string>
@@ -182,6 +190,8 @@
<string name="pref_theme_title_light">Light</string>
<string name="pref_theme_title_dark">Dark</string>
<string name="pref_episode_cache_unlimited">Unlimited</string>
+ <string name="pref_playback_speed_title">Playback Speed</string>
+ <string name="pref_playback_speed_sum">Change the speed of audio playback using a 3rd party control</string>
<!-- Search -->
<string name="search_hint">Search for Feeds or Episodes</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index b0968b79a..39c9fba64 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -17,6 +17,10 @@
android:key="prefFollowQueue"
android:summary="@string/pref_followQueue_sum"
android:title="@string/pref_followQueue_title" />
+ <Preference
+ android:key="prefPlaybackSpeedLauncher"
+ android:summary="@string/pref_playback_speed_sum"
+ android:title="@string/pref_playback_speed_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/network_pref" >
diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
index c59b14c03..a8b11bcbc 100644
--- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java
+++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
@@ -5,7 +5,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources.Theme;
import android.net.wifi.WifiConfiguration;
@@ -26,6 +28,7 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.asynctask.OpmlExportWorker;
+import de.danoeh.antennapod.dialog.GetSpeedPlaybackPlugin;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.util.flattr.FlattrUtils;
@@ -41,6 +44,7 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
private static final String PREF_ABOUT = "prefAbout";
private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir";
private static final String AUTO_DL_PREF_SCREEN = "prefAutoDownloadSettings";
+ private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher";
private CheckBoxPreference[] selectedNetworks;
@@ -166,6 +170,14 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
return true;
}
});
+ findPreference(PREF_PLAYBACK_SPEED_LAUNCHER)
+ .setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ setPlaybackSpeed();
+ return true;
+ }
+ });
buildAutodownloadSelectedNetworsPreference();
setSelectedNetworksEnabled(UserPreferences
@@ -224,6 +236,40 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
}
}
+ private void setPlaybackSpeed() {
+ if (com.aocate.media.MediaPlayer
+ .isPrestoLibraryInstalled(PreferenceActivity.this)) {
+ int currentIndex = 0;
+ final String[] speedValues = getResources().getStringArray(
+ R.array.playback_speed_values);
+ for (int i = 0; i < speedValues.length; i++) {
+ // Probably shouldn't float compare here...
+ if (Float.parseFloat(speedValues[i]) == UserPreferences
+ .getPlaybackSpeed()) {
+ currentIndex = i;
+ }
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ PreferenceActivity.this);
+ builder.setTitle(R.string.set_playback_speed_label);
+ builder.setSingleChoiceItems(R.array.playback_speed_values,
+ currentIndex, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ UserPreferences.setPlaybackSpeed(
+ PreferenceActivity.this,
+ Float.valueOf(speedValues[which]));
+ dialog.dismiss();
+
+ }
+ });
+ builder.create().show();
+
+ } else {
+ GetSpeedPlaybackPlugin.showDialog(this);
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
diff --git a/src/de/danoeh/antennapod/dialog/GetSpeedPlaybackPlugin.java b/src/de/danoeh/antennapod/dialog/GetSpeedPlaybackPlugin.java
new file mode 100644
index 000000000..f4aabfdeb
--- /dev/null
+++ b/src/de/danoeh/antennapod/dialog/GetSpeedPlaybackPlugin.java
@@ -0,0 +1,31 @@
+package de.danoeh.antennapod.dialog;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import de.danoeh.antennapod.R;
+
+public class GetSpeedPlaybackPlugin {
+ private GetSpeedPlaybackPlugin() {
+ }
+
+ public static void showDialog(final Context context) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(R.string.no_playback_plugin_title);
+ builder.setMessage(R.string.no_playback_plugin_msg);
+ builder.setNegativeButton(R.string.close_label, null);
+ builder.setPositiveButton(R.string.download_plugin_label,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent playStoreIntent = new Intent(
+ Intent.ACTION_VIEW,
+ Uri.parse("market://details?id=com.falconware.prestissimo"));
+ context.startActivity(playStoreIntent);
+ }
+ });
+ builder.create().show();
+ }
+}
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java
index f2f35f41d..0674849db 100644
--- a/src/de/danoeh/antennapod/preferences/UserPreferences.java
+++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java
@@ -17,6 +17,7 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
import de.danoeh.antennapod.receiver.FeedUpdateReceiver;
+import de.danoeh.antennapod.service.PlaybackService;
/**
* Provides access to preferences set by the user in the settings screen. A
@@ -41,11 +42,12 @@ public class UserPreferences implements
public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
+ private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
private static UserPreferences instance;
- private Context context;
+ private final Context context;
// Preferences
private boolean pauseOnHeadsetDisconnect;
@@ -60,6 +62,7 @@ public class UserPreferences implements
private boolean enableAutodownloadWifiFilter;
private String[] autodownloadSelectedNetworks;
private int episodeCacheSize;
+ private float playbackSpeed;
private UserPreferences(Context context) {
this.context = context;
@@ -108,6 +111,7 @@ public class UserPreferences implements
episodeCacheSize = readEpisodeCacheSize(sp.getString(
PREF_EPISODE_CACHE_SIZE, "20"));
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
+ playbackSpeed = sp.getFloat(PREF_PLAYBACK_SPEED, (float) 1.0);
}
private int readThemeValue(String valueFromPrefs) {
@@ -196,6 +200,11 @@ public class UserPreferences implements
return EPISODE_CACHE_SIZE_UNLIMITED;
}
+ public static float getPlaybackSpeed() {
+ instanceAvailable();
+ return instance.playbackSpeed;
+ }
+
/**
* Returns the capacity of the episode cache. This method will return the
* negative integer EPISODE_CACHE_SIZE_UNLIMITED if the cache size is set to
@@ -250,9 +259,23 @@ public class UserPreferences implements
PREF_EPISODE_CACHE_SIZE, "20"));
} else if (key.equals(PREF_ENABLE_AUTODL)) {
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
+ } else if (key.equals(PREF_PLAYBACK_SPEED)) {
+ playbackSpeed = sp.getFloat(PREF_PLAYBACK_SPEED, (float) 1.0);
}
}
+ public static void setPlaybackSpeed(Context context, float speed) {
+ SharedPreferences prefs = PreferenceManager
+ .getDefaultSharedPreferences(context.getApplicationContext());
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putFloat(PREF_PLAYBACK_SPEED, speed);
+ editor.apply();
+
+ Intent intent = new Intent(context, PlaybackService.class);
+ intent.putExtra(PlaybackService.EXTRA_PLAYBACK_SPEED, speed);
+ context.startService(intent);
+ }
+
public static void setAutodownloadSelectedNetworks(Context context,
String[] value) {
SharedPreferences.Editor editor = PreferenceManager
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 1d6d1448c..99d1afa7f 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -82,6 +82,7 @@ public class PlaybackService extends Service {
public static final String ACTION_PLAYER_NOTIFICATION = "action.de.danoeh.antennapod.service.playerNotification";
public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.service.notificationCode";
public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.service.notificationType";
+ public static final String EXTRA_PLAYBACK_SPEED = "extra.de.danoeh.antennapod.service.playbackSpeed";
/**
* If the PlaybackService receives this action, it will stop playback and
@@ -371,10 +372,17 @@ public class PlaybackService extends Service {
if (AppConfig.DEBUG)
Log.d(TAG, "OnStartCommand called");
int keycode = intent.getIntExtra(MediaButtonReceiver.EXTRA_KEYCODE, -1);
+ float playbackSpeed = intent.getFloatExtra(EXTRA_PLAYBACK_SPEED, -1);
if (keycode != -1) {
if (AppConfig.DEBUG)
Log.d(TAG, "Received media button event");
handleKeycode(keycode);
+ } else if (playbackSpeed > 0) {
+ if (media == null) {
+ stopSelf();
+ } else {
+ setSpeed(playbackSpeed);
+ }
} else {
Playable playable = intent.getParcelableExtra(EXTRA_PLAYABLE);
@@ -419,6 +427,7 @@ public class PlaybackService extends Service {
stopSelf();
}
}
+
return Service.START_NOT_STICKY;
}
@@ -976,6 +985,7 @@ public class PlaybackService extends Service {
Log.d(TAG, "Resuming/Starting playback");
writePlaybackPreferences();
+ setSpeed(UserPreferences.getPlaybackSpeed());
player.start();
if (status != PlayerStatus.PAUSED) {
player.seekTo(media.getPosition());
@@ -1534,20 +1544,20 @@ public class PlaybackService extends Service {
return false;
}
- public void setSpeed(double speed) {
+ public void setSpeed(float speed) {
if (media.getMediaType() == MediaType.AUDIO) {
AudioPlayer audioPlayer = (AudioPlayer) player;
if (audioPlayer.canSetSpeed()) {
- audioPlayer.setPlaybackSpeed((float) speed);
+ audioPlayer.setPlaybackSpeed(speed);
}
}
}
- public void setPitch(double pitch) {
+ public void setPitch(float pitch) {
if (media.getMediaType() == MediaType.AUDIO) {
AudioPlayer audioPlayer = (AudioPlayer) player;
if (audioPlayer.canSetPitch()) {
- audioPlayer.setPlaybackPitch((float) pitch);
+ audioPlayer.setPlaybackPitch(pitch);
}
}
}