Merge pull request #1266 from hubert-mazur:looped_playback
PiperOrigin-RevId: 625260110
This commit is contained in:
commit
236c341168
@ -48,6 +48,8 @@
|
||||
* Test Utilities:
|
||||
* Remove deprecated symbols:
|
||||
* Demo app:
|
||||
* Allow setting repeat mode with `Intent` arguments from command line
|
||||
([#1266](https://github.com/androidx/media/pull/1266)).
|
||||
|
||||
## 1.4
|
||||
|
||||
|
@ -27,6 +27,7 @@ import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MediaItem.ClippingConfiguration;
|
||||
import androidx.media3.common.MediaItem.SubtitleConfiguration;
|
||||
import androidx.media3.common.MediaMetadata;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.util.Util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.ArrayList;
|
||||
@ -66,6 +67,21 @@ public class IntentUtil {
|
||||
public static final String SUBTITLE_URI_EXTRA = "subtitle_uri";
|
||||
public static final String SUBTITLE_MIME_TYPE_EXTRA = "subtitle_mime_type";
|
||||
public static final String SUBTITLE_LANGUAGE_EXTRA = "subtitle_language";
|
||||
public static final String REPEAT_MODE_EXTRA = "repeat_mode";
|
||||
|
||||
public static @Player.RepeatMode int parseRepeatModeExtra(String repeatMode) {
|
||||
switch (repeatMode) {
|
||||
case "OFF":
|
||||
return Player.REPEAT_MODE_OFF;
|
||||
case "ONE":
|
||||
return Player.REPEAT_MODE_ONE;
|
||||
case "ALL":
|
||||
return Player.REPEAT_MODE_ALL;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Argument " + repeatMode + " does not match any of the repeat modes: OFF|ONE|ALL");
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a list of {@link MediaItem media items} from an {@link Intent}. */
|
||||
public static List<MediaItem> createMediaItemsFromIntent(Intent intent) {
|
||||
|
@ -262,8 +262,8 @@ public class PlayerActivity extends AppCompatActivity
|
||||
* @return Whether initialization was successful.
|
||||
*/
|
||||
protected boolean initializePlayer() {
|
||||
Intent intent = getIntent();
|
||||
if (player == null) {
|
||||
Intent intent = getIntent();
|
||||
|
||||
mediaItems = createMediaItems(intent);
|
||||
if (mediaItems.isEmpty()) {
|
||||
@ -293,6 +293,10 @@ public class PlayerActivity extends AppCompatActivity
|
||||
}
|
||||
player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);
|
||||
player.prepare();
|
||||
String repeatModeExtra = intent.getStringExtra(IntentUtil.REPEAT_MODE_EXTRA);
|
||||
if (repeatModeExtra != null) {
|
||||
player.setRepeatMode(IntentUtil.parseRepeatModeExtra(repeatModeExtra));
|
||||
}
|
||||
updateButtonVisibility();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user