mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Loop video option is available for autoplaying videos.
This commit is contained in:
parent
f12dea156f
commit
4de457cd02
@ -25,6 +25,7 @@ import im.ene.toro.exoplayer.ExoCreator;
|
|||||||
import im.ene.toro.exoplayer.MediaSourceBuilder;
|
import im.ene.toro.exoplayer.MediaSourceBuilder;
|
||||||
import im.ene.toro.exoplayer.ToroExo;
|
import im.ene.toro.exoplayer.ToroExo;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
|
import ml.docilealligator.infinityforreddit.customviews.LoopAvailableExoCreator;
|
||||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
@ -309,10 +310,10 @@ class AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ExoCreator provideExoCreator(SimpleCache simpleCache) {
|
ExoCreator provideExoCreator(SimpleCache simpleCache, @Named("default") SharedPreferences sharedPreferences) {
|
||||||
Config config = new Config.Builder(mApplication).setMediaSourceBuilder(MediaSourceBuilder.LOOPING).setCache(simpleCache)
|
Config config = new Config.Builder(mApplication).setMediaSourceBuilder(MediaSourceBuilder.DEFAULT).setCache(simpleCache)
|
||||||
.build();
|
.build();
|
||||||
return ToroExo.with(mApplication).getCreator(config);
|
return new LoopAvailableExoCreator(ToroExo.with(mApplication), config, sharedPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.customviews;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.Player;
|
||||||
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
|
|
||||||
|
import im.ene.toro.exoplayer.Config;
|
||||||
|
import im.ene.toro.exoplayer.DefaultExoCreator;
|
||||||
|
import im.ene.toro.exoplayer.ToroExo;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class LoopAvailableExoCreator extends DefaultExoCreator {
|
||||||
|
private final SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
public LoopAvailableExoCreator(@NonNull ToroExo toro, @NonNull Config config, SharedPreferences sharedPreferences) {
|
||||||
|
super(toro, config);
|
||||||
|
this.sharedPreferences = sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SimpleExoPlayer createPlayer() {
|
||||||
|
SimpleExoPlayer player = super.createPlayer();
|
||||||
|
if (sharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
|
||||||
|
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||||
|
} else {
|
||||||
|
player.setRepeatMode(Player.REPEAT_MODE_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
@ -595,6 +595,7 @@
|
|||||||
<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_loop_video_title">Loop Video</string>
|
||||||
|
<string name="settings_loop_video_summary">Restart the app to apply this setting to autoplaying videos</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>
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:key="loop_video"
|
app:key="loop_video"
|
||||||
app:title="@string/settings_loop_video_title" />
|
app:title="@string/settings_loop_video_title"
|
||||||
|
app:summary="@string/settings_loop_video_summary" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
app:title="@string/settings_video_autoplay_title" />
|
app:title="@string/settings_video_autoplay_title" />
|
||||||
|
Loading…
Reference in New Issue
Block a user