Skip to content

Commit

Permalink
Fix cleared metadata when repeating the same item
Browse files Browse the repository at this point in the history
Issue: #1007

#minor-release

PiperOrigin-RevId: 600477540
(cherry picked from commit c6bf380)
  • Loading branch information
tonihei authored and SheenaChhabra committed Jan 25, 2024
1 parent 50e0072 commit 5ac0c8b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
by wrapping an instance using the
[decorator pattern](https://en.wikipedia.org/wiki/Decorator_pattern) and
implementing a custom `CompositeSequenceableLoaderFactory`.
* Fix issue where repeating the same time causes metadata from this item
to be cleared ([#1007](https://github.com/androidx/media/issues/1007)).
* Transformer:
* Track Selection:
* Extractors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,8 @@ private void updatePlaybackInfo(
}
staticAndDynamicMediaMetadata = MediaMetadata.EMPTY;
}
if (!previousPlaybackInfo.staticMetadata.equals(newPlaybackInfo.staticMetadata)) {
if (mediaItemTransitioned
|| !previousPlaybackInfo.staticMetadata.equals(newPlaybackInfo.staticMetadata)) {
staticAndDynamicMediaMetadata =
staticAndDynamicMediaMetadata
.buildUpon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14227,6 +14227,33 @@ public void seekToZeroAndTrackSelection_withNonZeroDefaultPosition_startsPlaybac
assertThat(positionAfterSeek).isEqualTo(0);
}

@Test
public void repeatingItemWithSameStaticMetadata_keepsMetadata() throws Exception {
Format formatWithStaticMetadata =
new Format.Builder()
.setSampleMimeType(MimeTypes.VIDEO_H264)
.setMetadata(
new Metadata(
new BinaryFrame(/* id= */ "", /* data= */ new byte[0]),
new TextInformationFrame(
/* id= */ "TT2",
/* description= */ null,
/* values= */ ImmutableList.of("title"))))
.build();
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.setMediaSource(new FakeMediaSource(new FakeTimeline(), formatWithStaticMetadata));
player.prepare();
player.setRepeatMode(Player.REPEAT_MODE_ONE);
player.play();

// Wait until item repeats.
runUntilPositionDiscontinuity(player, Player.DISCONTINUITY_REASON_AUTO_TRANSITION);
MediaMetadata metadataAfterTransition = player.getMediaMetadata();
player.release();

assertThat(metadataAfterTransition.title).isEqualTo("title");
}

// Internal methods.

private void addWatchAsSystemFeature() {
Expand Down

0 comments on commit 5ac0c8b

Please sign in to comment.