Commit 19629513 by samrobinson Committed by Oliver Woodman

Populate MediaMetadata artwork from PictureFrame.

PiperOrigin-RevId: 378889901
parent aeeef654
...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.Util.castNonNull; ...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.Util.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import java.util.Arrays; import java.util.Arrays;
...@@ -74,6 +75,11 @@ public final class PictureFrame implements Metadata.Entry { ...@@ -74,6 +75,11 @@ public final class PictureFrame implements Metadata.Entry {
} }
@Override @Override
public void populateMediaMetadata(MediaMetadata.Builder builder) {
builder.setArtworkData(pictureData);
}
@Override
public String toString() { public String toString() {
return "Picture: mimeType=" + mimeType + ", description=" + description; return "Picture: mimeType=" + mimeType + ", description=" + description;
} }
......
...@@ -19,6 +19,9 @@ import static com.google.common.truth.Truth.assertThat; ...@@ -19,6 +19,9 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel; import android.os.Parcel;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -39,4 +42,25 @@ public final class PictureFrameTest { ...@@ -39,4 +42,25 @@ public final class PictureFrameTest {
parcel.recycle(); parcel.recycle();
} }
@Test
public void populateMediaMetadata_setsMediaMetadataValue() {
byte[] pictureData = new byte[] {-12, 52, 33, 85, 34, 22, 1, -55};
Metadata.Entry entry =
new PictureFrame(
/* pictureType= */ 0x03,
/* mimeType= */ MimeTypes.IMAGE_JPEG,
/* description= */ "an image",
/* width= */ 4,
/* height= */ 2,
/* depth= */ 1,
/* colors= */ 1,
pictureData);
MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();
entry.populateMediaMetadata(builder);
MediaMetadata mediaMetadata = builder.build();
assertThat(mediaMetadata.artworkData).isEqualTo(pictureData);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment