-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting repeat mode with Intent arguments #1266
Conversation
@@ -293,6 +293,9 @@ protected boolean initializePlayer() { | |||
} | |||
player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition); | |||
player.prepare(); | |||
if (getIntent().getBooleanExtra(IntentUtil.LOOP_PLAYBACK_EXTRA, false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind making a REPEAT_MODE_EXTRA
and a REPEAT_MODE_EXTRA_VALUE_NONE
, REPEAT_MODE_EXTRA_VALUE_ONE
, REPEAT_MODE_EXTRA_VALUE_ALL
so we cover the entire repeat mode API?
I understand the idea is to start the app directly into the PlayerActivity
from the command line. We have documented the Intent arguments we support here: https://developer.android.com/media/media3/exoplayer/demo-application#3-firing
I will document this on DAC once we have landed that change. The aim is to have an addition like the following
--es repeat_mode NONE | ONE | ALL
WDYT?
See https://gist.github.com/tsohr/5711945#file-gistfile1-txt-L81
Thanks for your PR! Please take a look at my suggestion in the comment! |
Thanks for the feedback! I'll do the changes and upload the second version soon. |
1daceb3
to
341cbb6
Compare
Hi, I uploaded the v2 of the change. Let me briefly describe the idea. Per suggestions, I changed the optional argument If provided, it is validated and set appropriately. In case of malicious input, the default (NONE) will be set. Please take a look and share your thoughts. |
I would suggest making this stricter:
The issue with silently falling back to a default is it can be quite confusing if someone expects You can see an existing example of an 'invalid parse' of an intent extra resulting in a failure by trying this:
This fails with an exception like:
Because we assume the array has an even length here: media/demos/main/src/main/java/androidx/media3/demo/main/IntentUtil.java Lines 176 to 178 in 8ba44ad
|
Ah, that way. Okay, this seems reasonable to fail if the argument is invalid. In that case, how about throwing an IllegalArgumentException out from |
Yep, sounds reasonable. IMO you can also remove the private static @Player.RepeatMode int parseRepeatMode(String repeatMode) {
switch (repeatMode) {
case "ALL":
return Player.REPEAT_MODE_ALL
...
default:
throw new IllegalArgumentException("Unrecognized repeat mode: '" + repeatMode "');
} |
341cbb6
to
1b80391
Compare
Thanks Ian for the hints! I pushed the changes. |
Add a new string command line optional argument to allow the playback to run in loop. This would help to use the app in the automated video tests. The change does not enable the option view for switching the loop mode in the UI as providing an extra argument implies force, not optional, loop playback. The extra option is provided with "repeat_mode" key and one of the possible modes can be specified: NONE|ONE|ALL. The available options correspond to the Player API to ensure compability.
1b80391
to
06cb067
Compare
I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks! |
06cb067
to
e7824b8
Compare
e1944d3
to
bfd5b84
Compare
bfd5b84
to
a6b5405
Compare
Add a new boolean command line optional argument to allow the playback to run in loop. This would help to use the app in the automated video tests. The change does not enable the option view for switching the loop mode in the UI as providing an extra argument implies force, not optional, loop playback.