Commit 428b9a32 authored by Donald's avatar Donald

Merge branch '263-feature-request-loop-videos' into 'dev'

Loop videos

See merge request !599
parents d97232bc 0574011b
Pipeline #28901986 passed with stage
in 8 minutes and 44 seconds
...@@ -81,6 +81,7 @@ import org.horaapps.leafpic.R; ...@@ -81,6 +81,7 @@ import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity; import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.Measure; import org.horaapps.leafpic.util.Measure;
import org.horaapps.leafpic.util.StringUtils; import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.util.preferences.Prefs;
import org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView; import org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView;
import org.horaapps.leafpic.views.videoplayer.CustomPlayBackController; import org.horaapps.leafpic.views.videoplayer.CustomPlayBackController;
import org.horaapps.leafpic.views.videoplayer.TrackSelectionHelper; import org.horaapps.leafpic.views.videoplayer.TrackSelectionHelper;
...@@ -138,11 +139,9 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro ...@@ -138,11 +139,9 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro
if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) { if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER); CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
} }
setContentView(R.layout.activity_player); setContentView(R.layout.activity_player);
initUi(); initUi();
rootView = findViewById(R.id.root); rootView = findViewById(R.id.root);
simpleExoPlayerView = findViewById(R.id.player_view); simpleExoPlayerView = findViewById(R.id.player_view);
simpleExoPlayerView.setControllerVisibilityListener(this); simpleExoPlayerView.setControllerVisibilityListener(this);
simpleExoPlayerView.requestFocus(); simpleExoPlayerView.requestFocus();
...@@ -234,7 +233,6 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro ...@@ -234,7 +233,6 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro
String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES); String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES);
boolean multiSession = intent.getBooleanExtra(DRM_MULTI_SESSION, false); boolean multiSession = intent.getBooleanExtra(DRM_MULTI_SESSION, false);
int errorStringId = R.string.error_drm_unknown; int errorStringId = R.string.error_drm_unknown;
try { try {
drmSessionManager = buildDrmSessionManagerV18(drmSchemeUuid, drmLicenseUrl, drmSessionManager = buildDrmSessionManagerV18(drmSchemeUuid, drmLicenseUrl,
keyRequestPropertiesArray, multiSession); keyRequestPropertiesArray, multiSession);
...@@ -247,15 +245,17 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro ...@@ -247,15 +245,17 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro
return; return;
} }
} }
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this, DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this,
drmSessionManager, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER); drmSessionManager, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER);
player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector); player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector);
player.addListener(new PlayerEventListener()); player.addListener(new PlayerEventListener());
simpleExoPlayerView.setPlayer(player); simpleExoPlayerView.setPlayer(player);
player.setPlayWhenReady(shouldAutoPlay); player.setPlayWhenReady(shouldAutoPlay);
if (Prefs.getLoopVideo()) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
} else {
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
} }
String action = intent.getAction(); String action = intent.getAction();
...@@ -442,7 +442,8 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro ...@@ -442,7 +442,8 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro
} }
} }
MenuItem loop = menu.findItem(R.id.loop_video);
loop.setChecked(Prefs.getLoopVideo());
return true; return true;
} }
...@@ -496,6 +497,18 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro ...@@ -496,6 +497,18 @@ public class PlayerActivity extends BaseActivity implements CustomPlayBackContro
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} }
return true; return true;
case R.id.loop_video:
if(item.isChecked()) {
item.setChecked(false);
Prefs.setLoopVideo(false);
player.setRepeatMode(Player.REPEAT_MODE_OFF);
} else {
item.setChecked(true);
Prefs.setLoopVideo(true);
player.setRepeatMode(Player.REPEAT_MODE_ALL);
}
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
......
...@@ -36,4 +36,5 @@ public final class Defaults { ...@@ -36,4 +36,5 @@ public final class Defaults {
public static final boolean ANIMATIONS_DISABLED = false; public static final boolean ANIMATIONS_DISABLED = false;
public static final boolean TIMELINE_ENABLED = false; public static final boolean TIMELINE_ENABLED = false;
public static final boolean LOOP_VIDEO = false;
} }
...@@ -28,6 +28,7 @@ public final class Keys { ...@@ -28,6 +28,7 @@ public final class Keys {
public static final String ANIMATIONS_DISABLED = "disable_animations"; public static final String ANIMATIONS_DISABLED = "disable_animations";
public static final String FORCE_ENGLISH = "force_english_locale"; public static final String FORCE_ENGLISH = "force_english_locale";
public static final String LOOP_VIDEO = "loop_video";
// Feature flags // Feature flags
public static final String TIMELINE_ENABLED = "enable_timeline"; public static final String TIMELINE_ENABLED = "enable_timeline";
......
...@@ -234,6 +234,14 @@ public class Prefs { ...@@ -234,6 +234,14 @@ public class Prefs {
return getPrefs().get(key, defaultValue); return getPrefs().get(key, defaultValue);
} }
public static boolean getLoopVideo() {
return getPrefs().get(Keys.LOOP_VIDEO, Defaults.LOOP_VIDEO);
}
public static void setLoopVideo(boolean value) {
getPrefs().put(Keys.LOOP_VIDEO, value);
}
// ***** Remove these methods when SettingWithSwitchView is refactored. // ***** Remove these methods when SettingWithSwitchView is refactored.
@NonNull @NonNull
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_share" android:id="@+id/action_share"
...@@ -24,6 +25,11 @@ ...@@ -24,6 +25,11 @@
android:title="@string/text" android:title="@string/text"
android:visible="false" android:visible="false"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/loop_video"
android:title="@string/loop_video"
android:checkable="true"
app:showAsAction="never"/>
<item <item
android:id="@+id/action_settings" android:id="@+id/action_settings"
android:title="@string/settings" android:title="@string/settings"
......
...@@ -337,6 +337,7 @@ ...@@ -337,6 +337,7 @@
<string name="text">Text</string> <string name="text">Text</string>
<string name="retry">Retry</string> <string name="retry">Retry</string>
<string name="off">Off</string> <string name="off">Off</string>
<string name="loop_video">Loop video</string>
<!--ERRORS--> <!--ERRORS-->
<string name="error_drm_not_supported">Protected content is supported on Android 4.3 and later</string> <string name="error_drm_not_supported">Protected content is supported on Android 4.3 and later</string>
...@@ -417,4 +418,7 @@ ...@@ -417,4 +418,7 @@
<string name="timeline_grouping_menu_month">Month</string> <string name="timeline_grouping_menu_month">Month</string>
<string name="timeline_grouping_menu_year">Year</string> <string name="timeline_grouping_menu_year">Year</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment