mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Populate MediaMetadata artwork from PictureFrame.
PiperOrigin-RevId: 378889901
This commit is contained in:
parent
aeeef65430
commit
19629513af
2 changed files with 30 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.Util.castNonNull;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.MediaMetadata;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
@ -73,6 +74,11 @@ public final class PictureFrame implements Metadata.Entry {
|
|||
this.pictureData = castNonNull(in.createByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateMediaMetadata(MediaMetadata.Builder builder) {
|
||||
builder.setArtworkData(pictureData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Picture: mimeType=" + mimeType + ", description=" + description;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
|
||||
import android.os.Parcel;
|
||||
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.runner.RunWith;
|
||||
|
||||
|
|
@ -39,4 +42,25 @@ public final class PictureFrameTest {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue