Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
22f05e54
authored
Jun 11, 2021
by
samrobinson
Committed by
Oliver Woodman
Jun 11, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Populate MediaMetadata from VorbisComment.
PiperOrigin-RevId: 378844617
parent
53d67daa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
library/common/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java
library/common/src/test/java/com/google/android/exoplayer2/metadata/flac/VorbisCommentTest.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java
View file @
22f05e54
...
@@ -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
;
/** A vorbis comment. */
/** A vorbis comment. */
...
@@ -46,6 +47,29 @@ public final class VorbisComment implements Metadata.Entry {
...
@@ -46,6 +47,29 @@ public final class VorbisComment implements Metadata.Entry {
}
}
@Override
@Override
public
void
populateMediaMetadata
(
MediaMetadata
.
Builder
builder
)
{
switch
(
key
)
{
case
"TITLE"
:
builder
.
setTitle
(
value
);
break
;
case
"ARTIST"
:
builder
.
setArtist
(
value
);
break
;
case
"ALBUM"
:
builder
.
setAlbumTitle
(
value
);
break
;
case
"ALBUMARTIST"
:
builder
.
setAlbumArtist
(
value
);
break
;
case
"DESCRIPTION"
:
builder
.
setDescription
(
value
);
break
;
default
:
break
;
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"VC: "
+
key
+
"="
+
value
;
return
"VC: "
+
key
+
"="
+
value
;
}
}
...
...
library/common/src/test/java/com/google/android/exoplayer2/metadata/flac/VorbisCommentTest.java
View file @
22f05e54
...
@@ -19,6 +19,10 @@ import static com.google.common.truth.Truth.assertThat;
...
@@ -19,6 +19,10 @@ 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.common.collect.ImmutableList
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -39,4 +43,32 @@ public final class VorbisCommentTest {
...
@@ -39,4 +43,32 @@ public final class VorbisCommentTest {
parcel
.
recycle
();
parcel
.
recycle
();
}
}
@Test
public
void
populateMediaMetadata_setsMediaMetadataValues
()
{
String
title
=
"the title"
;
String
artist
=
"artist"
;
String
albumTitle
=
"album title"
;
String
albumArtist
=
"album Artist"
;
String
description
=
"a description about the audio."
;
List
<
Metadata
.
Entry
>
entries
=
ImmutableList
.
of
(
new
VorbisComment
(
"TITLE"
,
title
),
new
VorbisComment
(
"ARTIST"
,
artist
),
new
VorbisComment
(
"ALBUM"
,
albumTitle
),
new
VorbisComment
(
"ALBUMARTIST"
,
albumArtist
),
new
VorbisComment
(
"DESCRIPTION"
,
description
));
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
for
(
Metadata
.
Entry
entry
:
entries
)
{
entry
.
populateMediaMetadata
(
builder
);
}
MediaMetadata
mediaMetadata
=
builder
.
build
();
assertThat
(
mediaMetadata
.
title
.
toString
()).
isEqualTo
(
title
);
assertThat
(
mediaMetadata
.
artist
.
toString
()).
isEqualTo
(
artist
);
assertThat
(
mediaMetadata
.
albumTitle
.
toString
()).
isEqualTo
(
albumTitle
);
assertThat
(
mediaMetadata
.
albumArtist
.
toString
()).
isEqualTo
(
albumArtist
);
assertThat
(
mediaMetadata
.
description
.
toString
()).
isEqualTo
(
description
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment