New option: loop video.

This commit is contained in:
Alex Ning 2021-10-09 21:43:55 +08:00
parent abd57e23a6
commit f12dea156f
8 changed files with 32 additions and 5 deletions

View File

@ -210,7 +210,11 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
videoPlayerView.setPlayer(player); videoPlayerView.setPlayer(player);
dataSourceFactory = new DefaultDataSourceFactory(this, dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "Infinity")); Util.getUserAgent(this, "Infinity"));
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);

View File

@ -419,7 +419,11 @@ public class ViewVideoActivity extends AppCompatActivity {
} }
private void preparePlayer(Bundle savedInstanceState) { private void preparePlayer(Bundle savedInstanceState) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
if (resumePosition > 0) { if (resumePosition > 0) {
player.seekTo(resumePosition); player.seekTo(resumePosition);
} }

View File

@ -222,7 +222,11 @@ public class ViewImgurVideoFragment extends Fragment {
} }
private void preparePlayer(Bundle savedInstanceState) { private void preparePlayer(Bundle savedInstanceState) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
wasPlaying = true; wasPlaying = true;
boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false); boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false);

View File

@ -343,7 +343,11 @@ public class ViewRPANBroadcastFragment extends Fragment {
dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(mActivity, "Infinity")); dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(mActivity, "Infinity"));
// Prepare the player with the source. // Prepare the player with the source.
player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(rpanBroadcast.rpanStream.hlsUrl))); player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(rpanBroadcast.rpanStream.hlsUrl)));
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
if (resumePosition > 0) { if (resumePosition > 0) {
player.seekTo(resumePosition); player.seekTo(resumePosition);
} }

View File

@ -226,7 +226,11 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
} }
private void preparePlayer(Bundle savedInstanceState) { private void preparePlayer(Bundle savedInstanceState) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
wasPlaying = true; wasPlaying = true;
boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false); boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false);

View File

@ -191,6 +191,7 @@ public class SharedPreferencesUtils {
public static final String USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER = "use_bottom_toolbar_in_media_viewer"; public static final String USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER = "use_bottom_toolbar_in_media_viewer";
public static final String LOCK_SCREEN_ANIMATION = "lock_screen_animation"; public static final String LOCK_SCREEN_ANIMATION = "lock_screen_animation";
public static final String ENABLE_FOLD_SUPPORT = "enable_fold_support"; public static final String ENABLE_FOLD_SUPPORT = "enable_fold_support";
public static final String LOOP_VIDEO = "loop_video";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";

View File

@ -594,6 +594,7 @@
<string name="settings_disable_nsfw_forever_title">Disable NSFW Forever</string> <string name="settings_disable_nsfw_forever_title">Disable NSFW Forever</string>
<string name="settings_show_only_one_comment_level_indicator">Show Only One Comment Level Indicator</string> <string name="settings_show_only_one_comment_level_indicator">Show Only One Comment Level Indicator</string>
<string name="settings_video_player_automatic_landscape_orientation">Switch to Landscape Orientation in Video Player Automatically</string> <string name="settings_video_player_automatic_landscape_orientation">Switch to Landscape Orientation in Video Player Automatically</string>
<string name="settings_loop_video_title">Loop Video</string>
<string name="settings_remember_muting_option_in_post_feed">Remember Muting Option in Post Feed</string> <string name="settings_remember_muting_option_in_post_feed">Remember Muting Option in Post Feed</string>
<string name="settings_post_details_title">Post Details</string> <string name="settings_post_details_title">Post Details</string>
<string name="settings_separate_post_and_comments_in_portrait_mode_title">Separate Post And Comments in Portrait Mode</string> <string name="settings_separate_post_and_comments_in_portrait_mode_title">Separate Post And Comments in Portrait Mode</string>

View File

@ -30,6 +30,11 @@
app:key="video_player_automatic_landscape_orientation" app:key="video_player_automatic_landscape_orientation"
app:title="@string/settings_video_player_automatic_landscape_orientation" /> app:title="@string/settings_video_player_automatic_landscape_orientation" />
<SwitchPreference
app:defaultValue="true"
app:key="loop_video"
app:title="@string/settings_loop_video_title" />
<PreferenceCategory <PreferenceCategory
app:title="@string/settings_video_autoplay_title" /> app:title="@string/settings_video_autoplay_title" />