feat: add global playback speed setting
This commit is contained in:
parent
b2c3efa02a
commit
fa79b2d73d
@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.schueller.peertube.fragment;
|
package net.schueller.peertube.fragment;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -72,8 +74,7 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
|
|||||||
TextView speed15 = view.findViewById(R.id.video_speed15);
|
TextView speed15 = view.findViewById(R.id.video_speed15);
|
||||||
TextView speed20 = view.findViewById(R.id.video_speed20);
|
TextView speed20 = view.findViewById(R.id.video_speed20);
|
||||||
|
|
||||||
// Default
|
setDefaultVideoSpeed();
|
||||||
setVideoSpeed(1.0f, speed10Icon);
|
|
||||||
|
|
||||||
// Attach the listener
|
// Attach the listener
|
||||||
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
|
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
|
||||||
@ -103,4 +104,30 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
|
|||||||
new Iconics.Builder().on(icon).build();
|
new Iconics.Builder().on(icon).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDefaultVideoSpeed() {
|
||||||
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
String speed = sharedPref.getString(getString(R.string.pref_video_speed_key), "1.0");
|
||||||
|
|
||||||
|
switch (speed) {
|
||||||
|
case "0.5":
|
||||||
|
setVideoSpeed(0.5f, speed05Icon);
|
||||||
|
break;
|
||||||
|
case "0.75":
|
||||||
|
setVideoSpeed(0.75f, speed075Icon);
|
||||||
|
break;
|
||||||
|
case "1.0":
|
||||||
|
setVideoSpeed(1.0f, speed10Icon);
|
||||||
|
break;
|
||||||
|
case "1.25":
|
||||||
|
setVideoSpeed(1.25f, speed125Icon);
|
||||||
|
break;
|
||||||
|
case "1.5":
|
||||||
|
setVideoSpeed(1.5f, speed15Icon);
|
||||||
|
break;
|
||||||
|
case "2.0":
|
||||||
|
setVideoSpeed(2.0f, speed20Icon);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -24,6 +24,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@ -32,6 +33,7 @@ import android.os.Binder;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
@ -255,8 +257,11 @@ public class VideoPlayerService extends Service {
|
|||||||
// Auto play
|
// Auto play
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(true);
|
||||||
|
|
||||||
//reset playback speed
|
//set playback speed to global default
|
||||||
this.setPlayBackSpeed(1.0f);
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
|
float speed = Float.parseFloat(sharedPref.getString(getString(R.string.pref_video_speed_key), "1.0"));
|
||||||
|
|
||||||
|
this.setPlayBackSpeed(speed);
|
||||||
|
|
||||||
playerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
|
playerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
|
||||||
context, PLAYBACK_CHANNEL_ID, R.string.playback_channel_name,
|
context, PLAYBACK_CHANNEL_ID, R.string.playback_channel_name,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<string name="pref_show_nsfw_key" translatable="false">pref_show_nsfw</string>
|
<string name="pref_show_nsfw_key" translatable="false">pref_show_nsfw</string>
|
||||||
<string name="pref_video_language_key" translatable="false">pref_language</string>
|
<string name="pref_video_language_key" translatable="false">pref_language</string>
|
||||||
|
|
||||||
|
<string name="pref_video_speed_key" translatable="false">pref_video_speed</string>
|
||||||
<string name="pref_back_pause_key" translatable="false">pref_back_pause</string>
|
<string name="pref_back_pause_key" translatable="false">pref_back_pause</string>
|
||||||
<string name="pref_background_behavior_key" translatable="false">pref_background_behavior</string>
|
<string name="pref_background_behavior_key" translatable="false">pref_background_behavior</string>
|
||||||
<string name="pref_torrent_player_key" translatable="false">pref_torrent_player</string>
|
<string name="pref_torrent_player_key" translatable="false">pref_torrent_player</string>
|
||||||
@ -582,4 +583,22 @@
|
|||||||
<item>High</item>
|
<item>High</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="videoSpeed">
|
||||||
|
<item>0.5x</item>
|
||||||
|
<item>0.75x</item>
|
||||||
|
<item>Normal</item>
|
||||||
|
<item>1.25x</item>
|
||||||
|
<item>1.5x</item>
|
||||||
|
<item>2x</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="videoSpeedValues">
|
||||||
|
<item>0.5</item>
|
||||||
|
<item>0.75</item>
|
||||||
|
<item>1.0</item>
|
||||||
|
<item>1.25</item>
|
||||||
|
<item>1.5</item>
|
||||||
|
<item>2.0</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -54,6 +54,8 @@
|
|||||||
<string name="pref_title_peertube_server">PeerTube Server</string>
|
<string name="pref_title_peertube_server">PeerTube Server</string>
|
||||||
<string name="pref_title_background_play">Background Playback</string>
|
<string name="pref_title_background_play">Background Playback</string>
|
||||||
<string name="pref_description_background_play">If enabled, continues to play video in background.</string>
|
<string name="pref_description_background_play">If enabled, continues to play video in background.</string>
|
||||||
|
<string name="pref_title_video_speed">Default Playback Speed</string>
|
||||||
|
<string name="pref_description_video_speed">Select the global Video Playback Speed</string>
|
||||||
<string name="pref_title_back_pause">Pause on back button</string>
|
<string name="pref_title_back_pause">Pause on back button</string>
|
||||||
<string name="pref_description_back_pause">Pause background play when pressing back during video playback.</string>
|
<string name="pref_description_back_pause">Pause background play when pressing back during video playback.</string>
|
||||||
<string name="pref_language_app">Application Language</string>
|
<string name="pref_language_app">Application Language</string>
|
||||||
|
@ -51,6 +51,15 @@
|
|||||||
|
|
||||||
<PreferenceCategory app:title="@string/settings_activity_video_playback_category_title" app:iconSpaceReserved="false">
|
<PreferenceCategory app:title="@string/settings_activity_video_playback_category_title" app:iconSpaceReserved="false">
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
app:defaultValue="1.0"
|
||||||
|
app:entries="@array/videoSpeed"
|
||||||
|
app:entryValues="@array/videoSpeedValues"
|
||||||
|
app:key="@string/pref_video_speed_key"
|
||||||
|
app:summary="@string/pref_description_video_speed"
|
||||||
|
app:title="@string/pref_title_video_speed"
|
||||||
|
app:iconSpaceReserved="false"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:key="@string/pref_back_pause_key"
|
app:key="@string/pref_back_pause_key"
|
||||||
|
Loading…
Reference in New Issue
Block a user