Minor cleanup

This commit is contained in:
Marc Baechinger 2024-04-15 11:09:13 +02:00
parent 20e98ca125
commit a6b540545d
3 changed files with 7 additions and 8 deletions

View file

@ -44,7 +44,7 @@
* Test Utilities:
* Remove deprecated symbols:
* Demo app:
* Allow setting repeat mode with Intent arguments from command line
* Allow setting repeat mode with `Intent` arguments from command line
([#1266](https://github.com/androidx/media/pull/1266)).
## 1.4

View file

@ -45,6 +45,7 @@ public class IntentUtil {
public static final String ACTION_VIEW_LIST = "androidx.media3.demo.main.action.VIEW_LIST";
// Activity extras.
public static final String AV_ANALYSIS_MODE_EXTRA = "av_analysis_mode"; // copybara:strip
public static final String PREFER_EXTENSION_DECODERS_EXTRA = "prefer_extension_decoders";
// Media item configuration extras.
@ -67,7 +68,7 @@ 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 PLAYER_REPEAT_MODE_EXTRA = "repeat_mode";
public static final String REPEAT_MODE_EXTRA = "repeat_mode";
public static @Player.RepeatMode int parseRepeatModeExtra(String repeatMode) {
switch (repeatMode) {

View file

@ -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,11 +293,9 @@ public class PlayerActivity extends AppCompatActivity
}
player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);
player.prepare();
String requestedRepeatModeExtra;
if ((requestedRepeatModeExtra =
this.getIntent().getStringExtra(IntentUtil.PLAYER_REPEAT_MODE_EXTRA))
!= null) {
player.setRepeatMode(IntentUtil.parseRepeatModeExtra(requestedRepeatModeExtra));
String repeatModeExtra = intent.getStringExtra(IntentUtil.REPEAT_MODE_EXTRA);
if (repeatModeExtra != null) {
player.setRepeatMode(IntentUtil.parseRepeatModeExtra(repeatModeExtra));
}
updateButtonVisibility();
return true;