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
9ec6992c
authored
Apr 01, 2021
by
samrobinson
Committed by
Oliver Woodman
Apr 06, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Populate MediaMetadata title from IcyInfo and TextInformationFrame.
PiperOrigin-RevId: 366272937
parent
a5c47243
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/TextInformationFrame.java
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
library/core/src/main/java/com/google/android/exoplayer2/metadata/icy/IcyInfo.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java
View file @
9ec6992c
...
...
@@ -19,6 +19,7 @@ import android.os.Parcel;
import
android.os.Parcelable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaMetadata
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -48,6 +49,13 @@ public final class Metadata implements Parcelable {
default
byte
[]
getWrappedMetadataBytes
()
{
return
null
;
}
/**
* Updates the {@link MediaMetadata.Builder} with the type specific values stored in this Entry.
*
* @param builder The builder to be updated.
*/
default
void
populateMediaMetadata
(
MediaMetadata
.
Builder
builder
)
{}
}
private
final
Entry
[]
entries
;
...
...
library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/TextInformationFrame.java
View file @
9ec6992c
...
...
@@ -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.util.Util
;
/**
...
...
@@ -43,6 +44,18 @@ public final class TextInformationFrame extends Id3Frame {
}
@Override
public
void
populateMediaMetadata
(
MediaMetadata
.
Builder
builder
)
{
switch
(
id
)
{
case
"TT2"
:
case
"TIT2"
:
builder
.
setTitle
(
value
);
break
;
default
:
break
;
}
}
@Override
public
boolean
equals
(
@Nullable
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
...
...
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
View file @
9ec6992c
...
...
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.id3.TextInformationFrame
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -47,4 +49,15 @@ public class MediaMetadataTest {
assertThat
(
MediaMetadata
.
CREATOR
.
fromBundle
(
mediaMetadata
.
toBundle
())).
isEqualTo
(
mediaMetadata
);
}
@Test
public
void
builderPopulatedFromMetadataEntry_setsTitleCorrectly
()
{
String
title
=
"the title"
;
Metadata
.
Entry
entry
=
new
TextInformationFrame
(
/* id= */
"TT2"
,
/* description= */
null
,
/* value= */
title
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
title
).
isEqualTo
(
title
);
}
}
library/core/src/main/java/com/google/android/exoplayer2/metadata/icy/IcyInfo.java
View file @
9ec6992c
...
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.metadata.icy;
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
com.google.android.exoplayer2.util.Assertions
;
import
java.util.Arrays
;
...
...
@@ -53,6 +54,13 @@ public final class IcyInfo implements Metadata.Entry {
}
@Override
public
void
populateMediaMetadata
(
MediaMetadata
.
Builder
builder
)
{
if
(
title
!=
null
)
{
builder
.
setTitle
(
title
);
}
}
@Override
public
boolean
equals
(
@Nullable
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
...
...
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