Added ExoPlayer setting
This commit is contained in:
parent
06dab67b03
commit
d50dcac96e
|
@ -52,7 +52,7 @@ public class VariableSpeedDialog {
|
|||
builder.neutralText(R.string.close_label);
|
||||
builder.onPositive((dialog, which) -> {
|
||||
if (Build.VERSION.SDK_INT >= 16) { // just to be safe
|
||||
UserPreferences.enableSonic(true);
|
||||
UserPreferences.enableSonic();
|
||||
if(showSpeedSelector) {
|
||||
showSpeedSelectorDialog(context);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.widget.Toast;
|
|||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import com.afollestad.materialdialogs.prefs.MaterialListPreference;
|
||||
import de.danoeh.antennapod.activity.ImportExportActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -135,12 +136,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if(key.equals(UserPreferences.PREF_SONIC)) {
|
||||
CheckBoxPreference prefSonic = (CheckBoxPreference) ui.findPreference(UserPreferences.PREF_SONIC);
|
||||
if(prefSonic != null) {
|
||||
prefSonic.setChecked(sharedPreferences.getBoolean(UserPreferences.PREF_SONIC, false));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
|
@ -707,11 +703,10 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
|
||||
ui.findPreference(PREF_SEND_CRASH_REPORT).setEnabled(CrashReportWriter.getFile().exists());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
ui.findPreference(UserPreferences.PREF_SONIC).setEnabled(true);
|
||||
} else {
|
||||
Preference prefSonic = ui.findPreference(UserPreferences.PREF_SONIC);
|
||||
prefSonic.setSummary("[Android 4.1+]\n" + prefSonic.getSummary());
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
MaterialListPreference p = ((MaterialListPreference) ui.findPreference(UserPreferences.PREF_MEDIA_PLAYER));
|
||||
p.setEntries(R.array.media_player_options_no_sonic);
|
||||
p.setEntryValues(R.array.media_player_values_no_sonic);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,12 +77,14 @@
|
|||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/playback_pref">
|
||||
<de.danoeh.antennapod.preferences.SwitchCompatPreference
|
||||
android:defaultValue="true"
|
||||
android:enabled="false"
|
||||
android:key="prefSonic"
|
||||
android:summary="@string/pref_sonic_message"
|
||||
android:title="@string/pref_sonic_title"/>
|
||||
<com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
android:defaultValue="sonic"
|
||||
android:entries="@array/media_player_options"
|
||||
android:key="prefMediaPlayer"
|
||||
android:title="@string/pref_media_player_title"
|
||||
android:summary="@string/pref_media_player_message"
|
||||
android:entryValues="@array/media_player_values"
|
||||
app:useStockLayout="true"/>
|
||||
<de.danoeh.antennapod.preferences.SwitchCompatPreference
|
||||
android:defaultValue="true"
|
||||
android:enabled="true"
|
||||
|
|
|
@ -89,7 +89,7 @@ class UpdateManager {
|
|||
}
|
||||
if(oldVersionCode < 1050004) {
|
||||
if(MediaPlayer.isPrestoLibraryInstalled(context) && Build.VERSION.SDK_INT >= 16) {
|
||||
UserPreferences.enableSonic(true);
|
||||
UserPreferences.enableSonic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ public class UserPreferences {
|
|||
public static final String PREF_IMAGE_CACHE_SIZE = "prefImageCacheSize";
|
||||
|
||||
// Mediaplayer
|
||||
public static final String PREF_MEDIA_PLAYER = "prefMediaPlayer";
|
||||
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
|
||||
private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs";
|
||||
private static final String PREF_REWIND_SECS = "prefRewindSecs";
|
||||
|
@ -113,7 +114,6 @@ public class UserPreferences {
|
|||
private static final String PREF_RIGHT_VOLUME = "prefRightVolume";
|
||||
|
||||
// Experimental
|
||||
public static final String PREF_SONIC = "prefSonic";
|
||||
private static final String PREF_STEREO_TO_MONO = "PrefStereoToMono";
|
||||
public static final String PREF_NORMALIZER = "prefNormalizer";
|
||||
public static final String PREF_CAST_ENABLED = "prefCast"; //Used for enabling Chromecast support
|
||||
|
@ -642,13 +642,15 @@ public class UserPreferences {
|
|||
}
|
||||
|
||||
public static boolean useSonic() {
|
||||
return prefs.getBoolean(PREF_SONIC, false);
|
||||
return prefs.getString(PREF_MEDIA_PLAYER, "sonic").equals("sonic");
|
||||
}
|
||||
|
||||
public static void enableSonic(boolean enable) {
|
||||
prefs.edit()
|
||||
.putBoolean(PREF_SONIC, enable)
|
||||
.apply();
|
||||
public static boolean useExoplayer() {
|
||||
return prefs.getString(PREF_MEDIA_PLAYER, "sonic").equals("exoplayer");
|
||||
}
|
||||
|
||||
public static void enableSonic() {
|
||||
prefs.edit().putString(PREF_MEDIA_PLAYER, "sonic").apply();
|
||||
}
|
||||
|
||||
public static boolean stereoToMono() {
|
||||
|
|
|
@ -25,7 +25,7 @@ import de.danoeh.antennapod.core.util.playback.IPlayer;
|
|||
import org.antennapod.audio.MediaPlayer;
|
||||
|
||||
|
||||
public class ExoPlayer implements IPlayer {
|
||||
public class ExoPlayerWrapper implements IPlayer {
|
||||
private final Context mContext;
|
||||
private SimpleExoPlayer mExoPlayer;
|
||||
private MediaSource mediaSource;
|
||||
|
@ -33,7 +33,7 @@ public class ExoPlayer implements IPlayer {
|
|||
private MediaPlayer.OnCompletionListener audioCompletionListener;
|
||||
private MediaPlayer.OnErrorListener audioErrorListener;
|
||||
|
||||
ExoPlayer(Context context) {
|
||||
ExoPlayerWrapper(Context context) {
|
||||
mContext = context;
|
||||
mExoPlayer = createPlayer();
|
||||
}
|
|
@ -313,8 +313,11 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
|
||||
Log.d(TAG, "Resource prepared");
|
||||
|
||||
if (mediaType == MediaType.VIDEO) {
|
||||
ExoPlayer vp = (ExoPlayer) mediaPlayer;
|
||||
if (mediaType == MediaType.VIDEO && mediaPlayer instanceof ExoPlayerWrapper) {
|
||||
ExoPlayerWrapper vp = (ExoPlayerWrapper) mediaPlayer;
|
||||
videoSize = new Pair<>(vp.getVideoWidth(), vp.getVideoHeight());
|
||||
} else if(mediaType == MediaType.VIDEO && mediaPlayer instanceof VideoPlayer) {
|
||||
VideoPlayer vp = (VideoPlayer) mediaPlayer;
|
||||
videoSize = new Pair<>(vp.getVideoWidth(), vp.getVideoHeight());
|
||||
}
|
||||
|
||||
|
@ -666,8 +669,12 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
Pair<Integer, Integer> res;
|
||||
if (mediaPlayer == null || playerStatus == PlayerStatus.ERROR || mediaType != MediaType.VIDEO) {
|
||||
res = null;
|
||||
} else if (mediaPlayer instanceof ExoPlayerWrapper) {
|
||||
ExoPlayerWrapper vp = (ExoPlayerWrapper) mediaPlayer;
|
||||
videoSize = new Pair<>(vp.getVideoWidth(), vp.getVideoHeight());
|
||||
res = videoSize;
|
||||
} else {
|
||||
ExoPlayer vp = (ExoPlayer) mediaPlayer;
|
||||
VideoPlayer vp = (VideoPlayer) mediaPlayer;
|
||||
videoSize = new Pair<>(vp.getVideoWidth(), vp.getVideoHeight());
|
||||
res = videoSize;
|
||||
}
|
||||
|
@ -695,11 +702,19 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
if (mediaPlayer != null) {
|
||||
mediaPlayer.release();
|
||||
}
|
||||
if(media == null) {
|
||||
if (media == null) {
|
||||
mediaPlayer = null;
|
||||
return;
|
||||
}
|
||||
mediaPlayer = new ExoPlayer(context);
|
||||
|
||||
if (UserPreferences.useExoplayer()) {
|
||||
mediaPlayer = new ExoPlayerWrapper(context);
|
||||
} else if (media.getMediaType() == MediaType.VIDEO) {
|
||||
mediaPlayer = new VideoPlayer();
|
||||
} else {
|
||||
mediaPlayer = new AudioPlayer(context);
|
||||
}
|
||||
|
||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
mediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
|
||||
setMediaPlayerListeners(mediaPlayer);
|
||||
|
@ -876,8 +891,8 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
ap.setOnBufferingUpdateListener(audioBufferingUpdateListener);
|
||||
ap.setOnInfoListener(audioInfoListener);
|
||||
ap.setOnSpeedAdjustmentAvailableChangedListener(audioSetSpeedAbilityListener);
|
||||
} else if (mp instanceof ExoPlayer) {
|
||||
ExoPlayer ap = (ExoPlayer) mp;
|
||||
} else if (mp instanceof ExoPlayerWrapper) {
|
||||
ExoPlayerWrapper ap = (ExoPlayerWrapper) mp;
|
||||
ap.setOnCompletionListener(audioCompletionListener);
|
||||
ap.setOnSeekCompleteListener(audioSeekCompleteListener);
|
||||
ap.setOnErrorListener(audioErrorListener);
|
||||
|
|
|
@ -21,7 +21,7 @@ public class AudioPlayer extends MediaPlayer implements IPlayer {
|
|||
|
||||
private final SharedPreferences.OnSharedPreferenceChangeListener sonicListener =
|
||||
(sharedPreferences, key) -> {
|
||||
if (key.equals(UserPreferences.PREF_SONIC)) {
|
||||
if (key.equals(UserPreferences.PREF_MEDIA_PLAYER)) {
|
||||
checkMpi();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -181,6 +181,28 @@
|
|||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="media_player_options">
|
||||
<item>@string/media_player_builtin</item>
|
||||
<item>@string/media_player_sonic</item>
|
||||
<item>@string/media_player_exoplayer</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="media_player_values">
|
||||
<item>builtin</item>
|
||||
<item>sonic</item>
|
||||
<item>exoplayer</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="media_player_options_no_sonic">
|
||||
<item>@string/media_player_builtin</item>
|
||||
<item>@string/media_player_exoplayer</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="media_player_values_no_sonic">
|
||||
<item>builtin</item>
|
||||
<item>exoplayer</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="episode_filter_options">
|
||||
<item>@string/hide_unplayed_episodes_label</item>
|
||||
<item>@string/hide_paused_episodes_label</item>
|
||||
|
|
|
@ -426,8 +426,8 @@
|
|||
<string name="crash_report_sum">Send the latest crash report via e-mail</string>
|
||||
<string name="send_email">Send e-mail</string>
|
||||
<string name="experimental_pref">Experimental</string>
|
||||
<string name="pref_sonic_title">Sonic Media Player</string>
|
||||
<string name="pref_sonic_message">Use built-in sonic media player as a replacement for Android\'s native mediaplayer and Prestissimo</string>
|
||||
<string name="pref_media_player_title">Media Player</string>
|
||||
<string name="pref_media_player_message">Select which media player to use to play files</string>
|
||||
<string name="pref_current_value">Current value: %1$s</string>
|
||||
<string name="pref_proxy_title">Proxy</string>
|
||||
<string name="pref_proxy_sum">Set a network proxy</string>
|
||||
|
@ -439,6 +439,9 @@
|
|||
<string name="pref_cast_message_free_flavor">Chromecast requires third party proprietary libraries that are disabled in this version of AntennaPod</string>
|
||||
<string name="pref_enqueue_downloaded_title">Enqueue Downloaded</string>
|
||||
<string name="pref_enqueue_downloaded_summary">Add downloaded episodes to the queue</string>
|
||||
<string name="media_player_builtin">Built-in Android player</string>
|
||||
<string name="media_player_sonic">Sonic Media Player</string>
|
||||
<string name="media_player_exoplayer">Exoplayer</string>
|
||||
|
||||
<!-- Auto-Flattr dialog -->
|
||||
<string name="auto_flattr_enable">Enable automatic flattring</string>
|
||||
|
|
Loading…
Reference in New Issue