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);
dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "Infinity"));
player.setRepeatMode(Player.REPEAT_MODE_ALL);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
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) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
if (resumePosition > 0) {
player.seekTo(resumePosition);
}

View File

@ -222,7 +222,11 @@ public class ViewImgurVideoFragment extends Fragment {
}
private void preparePlayer(Bundle savedInstanceState) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
wasPlaying = true;
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"));
// Prepare the player with the source.
player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(rpanBroadcast.rpanStream.hlsUrl)));
player.setRepeatMode(Player.REPEAT_MODE_ALL);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
if (resumePosition > 0) {
player.seekTo(resumePosition);
}

View File

@ -226,7 +226,11 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
}
private void preparePlayer(Bundle savedInstanceState) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
wasPlaying = true;
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 LOCK_SCREEN_ANIMATION = "lock_screen_animation";
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 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_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_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_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>

View File

@ -30,6 +30,11 @@
app:key="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
app:title="@string/settings_video_autoplay_title" />