diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c6490742d44..04fa2a68c30 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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: diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java index 2e304b46847..de0301b1490 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java @@ -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() diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java index 9a7e38dfd8d..d30d26ca3ae 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java @@ -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() {