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
7d81f20f
authored
Jun 15, 2021
by
samrobinson
Committed by
Oliver Woodman
Jun 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add disc fields to MediaMetadata.
PiperOrigin-RevId: 379469182
parent
f90d0a26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
library/common/src/main/java/com/google/android/exoplayer2/MediaMetadata.java
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
library/common/src/main/java/com/google/android/exoplayer2/MediaMetadata.java
View file @
7d81f20f
...
@@ -57,6 +57,8 @@ public final class MediaMetadata implements Bundleable {
...
@@ -57,6 +57,8 @@ public final class MediaMetadata implements Bundleable {
@Nullable
private
CharSequence
writer
;
@Nullable
private
CharSequence
writer
;
@Nullable
private
CharSequence
composer
;
@Nullable
private
CharSequence
composer
;
@Nullable
private
CharSequence
conductor
;
@Nullable
private
CharSequence
conductor
;
@Nullable
private
Integer
discNumber
;
@Nullable
private
Integer
totalDiscCount
;
@Nullable
private
Bundle
extras
;
@Nullable
private
Bundle
extras
;
public
Builder
()
{}
public
Builder
()
{}
...
@@ -82,6 +84,8 @@ public final class MediaMetadata implements Bundleable {
...
@@ -82,6 +84,8 @@ public final class MediaMetadata implements Bundleable {
this
.
writer
=
mediaMetadata
.
writer
;
this
.
writer
=
mediaMetadata
.
writer
;
this
.
composer
=
mediaMetadata
.
composer
;
this
.
composer
=
mediaMetadata
.
composer
;
this
.
conductor
=
mediaMetadata
.
conductor
;
this
.
conductor
=
mediaMetadata
.
conductor
;
this
.
discNumber
=
mediaMetadata
.
discNumber
;
this
.
totalDiscCount
=
mediaMetadata
.
totalDiscCount
;
this
.
extras
=
mediaMetadata
.
extras
;
this
.
extras
=
mediaMetadata
.
extras
;
}
}
...
@@ -209,6 +213,18 @@ public final class MediaMetadata implements Bundleable {
...
@@ -209,6 +213,18 @@ public final class MediaMetadata implements Bundleable {
return
this
;
return
this
;
}
}
/** Sets the disc number. */
public
Builder
setDiscNumber
(
@Nullable
Integer
discNumber
)
{
this
.
discNumber
=
discNumber
;
return
this
;
}
/** Sets the total number of discs. */
public
Builder
setTotalDiscCount
(
@Nullable
Integer
totalDiscCount
)
{
this
.
totalDiscCount
=
totalDiscCount
;
return
this
;
}
/** Sets the extras {@link Bundle}. */
/** Sets the extras {@link Bundle}. */
public
Builder
setExtras
(
@Nullable
Bundle
extras
)
{
public
Builder
setExtras
(
@Nullable
Bundle
extras
)
{
this
.
extras
=
extras
;
this
.
extras
=
extras
;
...
@@ -344,6 +360,10 @@ public final class MediaMetadata implements Bundleable {
...
@@ -344,6 +360,10 @@ public final class MediaMetadata implements Bundleable {
@Nullable
public
final
CharSequence
composer
;
@Nullable
public
final
CharSequence
composer
;
/** Optional conductor. */
/** Optional conductor. */
@Nullable
public
final
CharSequence
conductor
;
@Nullable
public
final
CharSequence
conductor
;
/** Optional disc number. */
@Nullable
public
final
Integer
discNumber
;
/** Optional total number of discs. */
@Nullable
public
final
Integer
totalDiscCount
;
/**
/**
* Optional extras {@link Bundle}.
* Optional extras {@link Bundle}.
...
@@ -374,6 +394,8 @@ public final class MediaMetadata implements Bundleable {
...
@@ -374,6 +394,8 @@ public final class MediaMetadata implements Bundleable {
this
.
writer
=
builder
.
writer
;
this
.
writer
=
builder
.
writer
;
this
.
composer
=
builder
.
composer
;
this
.
composer
=
builder
.
composer
;
this
.
conductor
=
builder
.
conductor
;
this
.
conductor
=
builder
.
conductor
;
this
.
discNumber
=
builder
.
discNumber
;
this
.
totalDiscCount
=
builder
.
totalDiscCount
;
this
.
extras
=
builder
.
extras
;
this
.
extras
=
builder
.
extras
;
}
}
...
@@ -410,7 +432,9 @@ public final class MediaMetadata implements Bundleable {
...
@@ -410,7 +432,9 @@ public final class MediaMetadata implements Bundleable {
&&
Util
.
areEqual
(
year
,
that
.
year
)
&&
Util
.
areEqual
(
year
,
that
.
year
)
&&
Util
.
areEqual
(
writer
,
that
.
writer
)
&&
Util
.
areEqual
(
writer
,
that
.
writer
)
&&
Util
.
areEqual
(
composer
,
that
.
composer
)
&&
Util
.
areEqual
(
composer
,
that
.
composer
)
&&
Util
.
areEqual
(
conductor
,
that
.
conductor
);
&&
Util
.
areEqual
(
conductor
,
that
.
conductor
)
&&
Util
.
areEqual
(
discNumber
,
that
.
discNumber
)
&&
Util
.
areEqual
(
totalDiscCount
,
that
.
totalDiscCount
);
}
}
@Override
@Override
...
@@ -432,10 +456,12 @@ public final class MediaMetadata implements Bundleable {
...
@@ -432,10 +456,12 @@ public final class MediaMetadata implements Bundleable {
totalTrackCount
,
totalTrackCount
,
folderType
,
folderType
,
isPlayable
,
isPlayable
,
year
,
writer
,
writer
,
composer
,
composer
,
conductor
,
conductor
,
year
);
discNumber
,
totalDiscCount
);
}
}
// Bundleable implementation.
// Bundleable implementation.
...
@@ -463,6 +489,8 @@ public final class MediaMetadata implements Bundleable {
...
@@ -463,6 +489,8 @@ public final class MediaMetadata implements Bundleable {
FIELD_WRITER
,
FIELD_WRITER
,
FIELD_COMPOSER
,
FIELD_COMPOSER
,
FIELD_CONDUCTOR
,
FIELD_CONDUCTOR
,
FIELD_DISC_NUMBER
,
FIELD_TOTAL_DISC_COUNT
,
FIELD_EXTRAS
FIELD_EXTRAS
})
})
private
@interface
FieldNumber
{}
private
@interface
FieldNumber
{}
...
@@ -487,6 +515,8 @@ public final class MediaMetadata implements Bundleable {
...
@@ -487,6 +515,8 @@ public final class MediaMetadata implements Bundleable {
private
static
final
int
FIELD_WRITER
=
17
;
private
static
final
int
FIELD_WRITER
=
17
;
private
static
final
int
FIELD_COMPOSER
=
18
;
private
static
final
int
FIELD_COMPOSER
=
18
;
private
static
final
int
FIELD_CONDUCTOR
=
19
;
private
static
final
int
FIELD_CONDUCTOR
=
19
;
private
static
final
int
FIELD_DISC_NUMBER
=
20
;
private
static
final
int
FIELD_TOTAL_DISC_COUNT
=
21
;
private
static
final
int
FIELD_EXTRAS
=
1000
;
private
static
final
int
FIELD_EXTRAS
=
1000
;
@Override
@Override
...
@@ -527,6 +557,12 @@ public final class MediaMetadata implements Bundleable {
...
@@ -527,6 +557,12 @@ public final class MediaMetadata implements Bundleable {
if
(
year
!=
null
)
{
if
(
year
!=
null
)
{
bundle
.
putInt
(
keyForField
(
FIELD_YEAR
),
year
);
bundle
.
putInt
(
keyForField
(
FIELD_YEAR
),
year
);
}
}
if
(
discNumber
!=
null
)
{
bundle
.
putInt
(
keyForField
(
FIELD_DISC_NUMBER
),
discNumber
);
}
if
(
totalDiscCount
!=
null
)
{
bundle
.
putInt
(
keyForField
(
FIELD_TOTAL_DISC_COUNT
),
totalDiscCount
);
}
if
(
extras
!=
null
)
{
if
(
extras
!=
null
)
{
bundle
.
putBundle
(
keyForField
(
FIELD_EXTRAS
),
extras
);
bundle
.
putBundle
(
keyForField
(
FIELD_EXTRAS
),
extras
);
}
}
...
@@ -581,6 +617,12 @@ public final class MediaMetadata implements Bundleable {
...
@@ -581,6 +617,12 @@ public final class MediaMetadata implements Bundleable {
if
(
bundle
.
containsKey
(
keyForField
(
FIELD_YEAR
)))
{
if
(
bundle
.
containsKey
(
keyForField
(
FIELD_YEAR
)))
{
builder
.
setYear
(
bundle
.
getInt
(
keyForField
(
FIELD_YEAR
)));
builder
.
setYear
(
bundle
.
getInt
(
keyForField
(
FIELD_YEAR
)));
}
}
if
(
bundle
.
containsKey
(
keyForField
(
FIELD_DISC_NUMBER
)))
{
builder
.
setDiscNumber
(
bundle
.
getInt
(
keyForField
(
FIELD_DISC_NUMBER
)));
}
if
(
bundle
.
containsKey
(
keyForField
(
FIELD_TOTAL_DISC_COUNT
)))
{
builder
.
setTotalDiscCount
(
bundle
.
getInt
(
keyForField
(
FIELD_TOTAL_DISC_COUNT
)));
}
return
builder
.
build
();
return
builder
.
build
();
}
}
...
...
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
View file @
7d81f20f
...
@@ -58,6 +58,8 @@ public class MediaMetadataTest {
...
@@ -58,6 +58,8 @@ public class MediaMetadataTest {
assertThat
(
mediaMetadata
.
composer
).
isNull
();
assertThat
(
mediaMetadata
.
composer
).
isNull
();
assertThat
(
mediaMetadata
.
conductor
).
isNull
();
assertThat
(
mediaMetadata
.
conductor
).
isNull
();
assertThat
(
mediaMetadata
.
writer
).
isNull
();
assertThat
(
mediaMetadata
.
writer
).
isNull
();
assertThat
(
mediaMetadata
.
discNumber
).
isNull
();
assertThat
(
mediaMetadata
.
totalDiscCount
).
isNull
();
assertThat
(
mediaMetadata
.
extras
).
isNull
();
assertThat
(
mediaMetadata
.
extras
).
isNull
();
}
}
...
@@ -107,6 +109,8 @@ public class MediaMetadataTest {
...
@@ -107,6 +109,8 @@ public class MediaMetadataTest {
.
setComposer
(
"Composer"
)
.
setComposer
(
"Composer"
)
.
setConductor
(
"Conductor"
)
.
setConductor
(
"Conductor"
)
.
setWriter
(
"Writer"
)
.
setWriter
(
"Writer"
)
.
setDiscNumber
(
1
)
.
setTotalDiscCount
(
3
)
.
setExtras
(
extras
)
// Extras is not implemented in MediaMetadata.equals(Object o).
.
setExtras
(
extras
)
// Extras is not implemented in MediaMetadata.equals(Object o).
.
build
();
.
build
();
...
...
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