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
d47d1ebf
authored
Jul 20, 2021
by
samrobinson
Committed by
Ian Baker
Jul 21, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Deprecate static metadata getter and listener method.
PiperOrigin-RevId: 385781004
parent
fa9a4521
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
48 additions
and
137 deletions
RELEASENOTES.md
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java
library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
RELEASENOTES.md
View file @
d47d1ebf
...
...
@@ -41,6 +41,13 @@
*
Add a
`DefaultMediaDescriptionAdapter`
for the
`PlayerNotificationManager`
, that makes use of the
`Player`
`MediaMetadata`
to populate the notification fields.
*
Deprecate
`Player.getCurrentStaticMetadata`
,
`Player.Listener.onStaticMetadataChanged`
and
`Player.EVENT_STATIC_METADATA_CHANGED`
. Use
`Player.getMediaMetadata`
,
`Player.Listener.onMediaMetadataChanged`
and
`Player.EVENT_MEDIA_METADATA_CHANGED`
for convenient access to
structured metadata, or access the raw static metadata directly from
the
`TrackSelection#getFormat()`
.
*
Remove deprecated symbols:
*
Remove
`Player.getPlaybackError`
. Use
`Player.getPlayerError`
instead.
*
Remove
`Player.getCurrentTag`
. Use
`Player.getCurrentMediaItem`
and
...
...
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
d47d1ebf
...
...
@@ -541,6 +541,7 @@ public final class CastPlayer extends BasePlayer {
return
currentTrackGroups
;
}
@Deprecated
@Override
public
ImmutableList
<
Metadata
>
getCurrentStaticMetadata
()
{
// CastPlayer does not currently support metadata.
...
...
library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java
View file @
d47d1ebf
...
...
@@ -367,6 +367,7 @@ public class ForwardingPlayer implements Player {
return
player
.
getCurrentTrackSelections
();
}
@Deprecated
@Override
public
List
<
Metadata
>
getCurrentStaticMetadata
()
{
return
player
.
getCurrentStaticMetadata
();
...
...
@@ -642,6 +643,7 @@ public class ForwardingPlayer implements Player {
eventListener
.
onTracksChanged
(
trackGroups
,
trackSelections
);
}
@Deprecated
@Override
public
void
onStaticMetadataChanged
(
List
<
Metadata
>
metadataList
)
{
eventListener
.
onStaticMetadataChanged
(
metadataList
);
...
...
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
d47d1ebf
...
...
@@ -32,6 +32,7 @@ import com.google.android.exoplayer2.metadata.MetadataOutput;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.TextOutput
;
import
com.google.android.exoplayer2.trackselection.TrackSelection
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.util.FlagSet
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -128,30 +129,20 @@ public interface Player {
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{}
/**
* Called when the static metadata changes.
*
* <p>The provided {@code metadataList} is an immutable list of {@link Metadata} instances,
* where the elements correspond to the {@link #getCurrentTrackSelections() current track
* selections}, or an empty list if there are no track selections or the selected tracks contain
* no static metadata.
*
* <p>The metadata is considered static in the sense that it comes from the tracks' declared
* Formats, rather than being timed (or dynamic) metadata, which is represented within a
* metadata track.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param metadataList The static metadata.
* @deprecated Use {@link Player#getMediaMetadata()} and {@link
* #onMediaMetadataChanged(MediaMetadata)} for access to structured metadata, or access the
* raw static metadata directly from the {@link TrackSelection#getFormat(int) track
* selections' formats}.
*/
@Deprecated
default
void
onStaticMetadataChanged
(
List
<
Metadata
>
metadataList
)
{}
/**
* Called when the combined {@link MediaMetadata} changes.
*
* <p>The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata}
* and the static and dynamic metadata
sourced from {@link #onStaticMetadataChanged(List)} and
* {@link MetadataOutput#onMetadata(Metadata)}.
* and the static and dynamic metadata
from the {@link TrackSelection#getFormat(int) track
*
selections' formats} and
{@link MetadataOutput#onMetadata(Metadata)}.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
...
...
@@ -987,9 +978,6 @@ public interface Player {
@Override
default
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
@Override
default
void
onStaticMetadataChanged
(
List
<
Metadata
>
metadataList
)
{}
}
/**
...
...
@@ -1215,8 +1203,8 @@ public interface Player {
int
EVENT_MEDIA_ITEM_TRANSITION
=
1
;
/** {@link #getCurrentTrackGroups()} or {@link #getCurrentTrackSelections()} changed. */
int
EVENT_TRACKS_CHANGED
=
2
;
/**
{@link #getCurrentStaticMetadata()} changed
. */
int
EVENT_STATIC_METADATA_CHANGED
=
3
;
/**
@deprecated Use {@link #EVENT_MEDIA_METADATA_CHANGED} for structured metadata changes
. */
@Deprecated
int
EVENT_STATIC_METADATA_CHANGED
=
3
;
/** {@link #isLoading()} ()} changed. */
int
EVENT_IS_LOADING_CHANGED
=
4
;
/** {@link #getPlaybackState()} changed. */
...
...
@@ -1926,18 +1914,12 @@ public interface Player {
TrackSelectionArray
getCurrentTrackSelections
();
/**
* Returns the current static metadata for the track selections.
*
* <p>The returned {@code metadataList} is an immutable list of {@link Metadata} instances, where
* the elements correspond to the {@link #getCurrentTrackSelections() current track selections},
* or an empty list if there are no track selections or the selected tracks contain no static
* metadata.
*
* <p>This metadata is considered static in that it comes from the tracks' declared Formats,
* rather than being timed (or dynamic) metadata, which is represented within a metadata track.
*
* @see Listener#onStaticMetadataChanged(List)
* @deprecated Use {@link #getMediaMetadata()} and {@link
* Listener#onMediaMetadataChanged(MediaMetadata)} for access to structured metadata, or
* access the raw static metadata directly from the {@link TrackSelection#getFormat(int) track
* selections' formats}.
*/
@Deprecated
List
<
Metadata
>
getCurrentStaticMetadata
();
/**
...
...
@@ -1945,8 +1927,8 @@ public interface Player {
* supported.
*
* <p>This {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata} and the
* static and dynamic metadata
sourced from {@link Listener#onStaticMetadataChanged(List)} and
* {@link MetadataOutput#onMetadata(Metadata)}.
* static and dynamic metadata
from the {@link TrackSelection#getFormat(int) track selections'
*
formats} and
{@link MetadataOutput#onMetadata(Metadata)}.
*/
MediaMetadata
getMediaMetadata
();
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
d47d1ebf
...
...
@@ -1004,6 +1004,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
return
new
TrackSelectionArray
(
playbackInfo
.
trackSelectorResult
.
selections
);
}
@Deprecated
@Override
public
List
<
Metadata
>
getCurrentStaticMetadata
()
{
return
playbackInfo
.
staticMetadata
;
...
...
@@ -1264,7 +1265,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
.
windowIndex
;
mediaItem
=
newPlaybackInfo
.
timeline
.
getWindow
(
windowIndex
,
window
).
mediaItem
;
}
m
ediaMetadata
=
mediaItem
!=
null
?
mediaItem
.
mediaMetadata
:
MediaMetadata
.
EMPTY
;
newM
ediaMetadata
=
mediaItem
!=
null
?
mediaItem
.
mediaMetadata
:
MediaMetadata
.
EMPTY
;
}
if
(!
previousPlaybackInfo
.
staticMetadata
.
equals
(
newPlaybackInfo
.
staticMetadata
))
{
newMediaMetadata
=
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
d47d1ebf
...
...
@@ -1723,6 +1723,7 @@ public class SimpleExoPlayer extends BasePlayer
return
player
.
getCurrentTrackSelections
();
}
@Deprecated
@Override
public
List
<
Metadata
>
getCurrentStaticMetadata
()
{
verifyApplicationThread
();
...
...
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java
View file @
d47d1ebf
...
...
@@ -595,6 +595,7 @@ public class AnalyticsCollector
listener
->
listener
.
onTracksChanged
(
eventTime
,
trackGroups
,
trackSelections
));
}
@Deprecated
@Override
public
final
void
onStaticMetadataChanged
(
List
<
Metadata
>
metadataList
)
{
EventTime
eventTime
=
generateCurrentPlayerMediaPeriodEventTime
();
...
...
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java
View file @
d47d1ebf
...
...
@@ -48,6 +48,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo;
import
com.google.android.exoplayer2.source.MediaLoadData
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelection
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.util.FlagSet
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer
;
...
...
@@ -225,8 +226,8 @@ public interface AnalyticsListener {
* {@link Player#getCurrentTrackGroups()} or {@link Player#getCurrentTrackSelections()} changed.
*/
int
EVENT_TRACKS_CHANGED
=
Player
.
EVENT_TRACKS_CHANGED
;
/**
{@link Player#getCurrentStaticMetadata()} changed
. */
int
EVENT_STATIC_METADATA_CHANGED
=
Player
.
EVENT_STATIC_METADATA_CHANGED
;
/**
@deprecated See {@link Player#EVENT_MEDIA_METADATA_CHANGED}
. */
@Deprecated
int
EVENT_STATIC_METADATA_CHANGED
=
Player
.
EVENT_STATIC_METADATA_CHANGED
;
/** {@link Player#isLoading()} ()} changed. */
int
EVENT_IS_LOADING_CHANGED
=
Player
.
EVENT_IS_LOADING_CHANGED
;
/** {@link Player#getPlaybackState()} changed. */
...
...
@@ -682,28 +683,19 @@ public interface AnalyticsListener {
EventTime
eventTime
,
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{}
/**
* Called when the static metadata changes.
*
* <p>The provided {@code metadataList} is an immutable list of {@link Metadata} instances, where
* the elements correspond to the current track selections (as returned by {@link
* #onTracksChanged(EventTime, TrackGroupArray, TrackSelectionArray)}, or an empty list if there
* are no track selections or the selected tracks contain no static metadata.
*
* <p>The metadata is considered static in the sense that it comes from the tracks' declared
* Formats, rather than being timed (or dynamic) metadata, which is represented within a metadata
* track.
*
* @param eventTime The event time.
* @param metadataList The static metadata.
* @deprecated Use {@link Player#getMediaMetadata()} and {@link #onMediaMetadataChanged(EventTime,
* MediaMetadata)} for access to structured metadata, or access the raw static metadata
* directly from the {@link TrackSelection#getFormat(int) track selections' formats}.
*/
@Deprecated
default
void
onStaticMetadataChanged
(
EventTime
eventTime
,
List
<
Metadata
>
metadataList
)
{}
/**
* Called when the combined {@link MediaMetadata} changes.
*
* <p>The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata}
* and the static and dynamic metadata
sourced from {@lin
k
*
Player.Listener#onStaticMetadataChanged(List)
} and {@link MetadataOutput#onMetadata(Metadata)}.
* and the static and dynamic metadata
from the {@link TrackSelection#getFormat(int) trac
k
*
selections' formats
} and {@link MetadataOutput#onMetadata(Metadata)}.
*
* @param eventTime The event time.
* @param mediaMetadata The combined {@link MediaMetadata}.
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java
View file @
d47d1ebf
...
...
@@ -47,7 +47,6 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import
com.google.android.exoplayer2.video.VideoSize
;
import
java.io.IOException
;
import
java.text.NumberFormat
;
import
java.util.List
;
import
java.util.Locale
;
/** Logs events from {@link Player} and other core components using {@link Log}. */
...
...
@@ -335,20 +334,6 @@ public class EventLogger implements AnalyticsListener {
}
@Override
public
void
onStaticMetadataChanged
(
EventTime
eventTime
,
List
<
Metadata
>
metadataList
)
{
logd
(
"staticMetadata ["
+
getEventTimeString
(
eventTime
));
for
(
int
i
=
0
;
i
<
metadataList
.
size
();
i
++)
{
Metadata
metadata
=
metadataList
.
get
(
i
);
if
(
metadata
.
length
()
!=
0
)
{
logd
(
" Metadata:"
+
i
+
" ["
);
printMetadata
(
metadata
,
" "
);
logd
(
" ]"
);
}
}
logd
(
"]"
);
}
@Override
public
void
onMetadata
(
EventTime
eventTime
,
Metadata
metadata
)
{
logd
(
"metadata ["
+
getEventTimeString
(
eventTime
));
printMetadata
(
metadata
,
" "
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
d47d1ebf
...
...
@@ -8938,72 +8938,6 @@ public final class ExoPlayerTest {
}
@Test
public
void
staticMetadata_callbackIsCalledCorrectlyAndMatchesGetter
()
throws
Exception
{
Format
videoFormat
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setMetadata
(
new
Metadata
(
new
TextInformationFrame
(
/* id= */
"TT2"
,
/* description= */
"Video"
,
/* value= */
"Video track name"
)))
.
build
();
Format
audioFormat
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
)
.
setMetadata
(
new
Metadata
(
new
TextInformationFrame
(
/* id= */
"TT2"
,
/* description= */
"Audio"
,
/* value= */
"Audio track name"
)))
.
build
();
Player
.
Listener
playerListener
=
mock
(
Player
.
Listener
.
class
);
Timeline
fakeTimeline
=
new
FakeTimeline
(
new
TimelineWindowDefinition
(
/* isSeekable= */
true
,
/* isDynamic= */
false
,
/* durationUs= */
100000
));
SimpleExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
setMediaSource
(
new
FakeMediaSource
(
fakeTimeline
,
videoFormat
,
audioFormat
));
player
.
addListener
(
playerListener
);
player
.
prepare
();
player
.
play
();
runUntilPlaybackState
(
player
,
Player
.
STATE_ENDED
);
List
<
Metadata
>
metadata
=
player
.
getCurrentStaticMetadata
();
player
.
release
();
assertThat
(
metadata
).
containsExactly
(
videoFormat
.
metadata
,
audioFormat
.
metadata
).
inOrder
();
verify
(
playerListener
)
.
onStaticMetadataChanged
(
ImmutableList
.
of
(
videoFormat
.
metadata
,
audioFormat
.
metadata
));
}
@Test
public
void
staticMetadata_callbackIsNotCalledWhenMetadataEmptyAndGetterReturnsEmptyList
()
throws
Exception
{
Format
videoFormat
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
).
build
();
Format
audioFormat
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
).
build
();
Player
.
Listener
playerListener
=
mock
(
Player
.
Listener
.
class
);
Timeline
fakeTimeline
=
new
FakeTimeline
(
new
TimelineWindowDefinition
(
/* isSeekable= */
true
,
/* isDynamic= */
false
,
/* durationUs= */
100000
));
SimpleExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
setMediaSource
(
new
FakeMediaSource
(
fakeTimeline
,
videoFormat
,
audioFormat
));
player
.
addListener
(
playerListener
);
player
.
prepare
();
player
.
play
();
runUntilPlaybackState
(
player
,
Player
.
STATE_ENDED
);
List
<
Metadata
>
metadata
=
player
.
getCurrentStaticMetadata
();
player
.
release
();
assertThat
(
metadata
).
isEmpty
();
verify
(
playerListener
,
never
()).
onStaticMetadataChanged
(
any
());
}
@Test
public
void
targetLiveOffsetInMedia_adjustsLiveOffsetToTargetOffset
()
throws
Exception
{
long
windowStartUnixTimeMs
=
987_654_321_000L
;
long
nowUnixTimeMs
=
windowStartUnixTimeMs
+
20_000
;
...
...
@@ -9495,7 +9429,11 @@ public final class ExoPlayerTest {
Format
formatWithStaticMetadata
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setMetadata
(
new
Metadata
(
new
BinaryFrame
(
/* id= */
""
,
/* data= */
new
byte
[
0
])))
.
setMetadata
(
new
Metadata
(
new
BinaryFrame
(
/* id= */
""
,
/* data= */
new
byte
[
0
]),
new
TextInformationFrame
(
/* id= */
"TT2"
,
/* description= */
null
,
/* value= */
"title"
)))
.
build
();
// Set multiple values together.
...
...
@@ -9554,7 +9492,7 @@ public final class ExoPlayerTest {
verify
(
listener
,
atLeastOnce
()).
onPlaybackStateChanged
(
anyInt
());
verify
(
listener
,
atLeastOnce
()).
onIsLoadingChanged
(
anyBoolean
());
verify
(
listener
,
atLeastOnce
()).
onTracksChanged
(
any
(),
any
());
verify
(
listener
,
atLeastOnce
()).
on
Static
MetadataChanged
(
any
());
verify
(
listener
,
atLeastOnce
()).
on
Media
MetadataChanged
(
any
());
verify
(
listener
,
atLeastOnce
()).
onPlayWhenReadyChanged
(
anyBoolean
(),
anyInt
());
verify
(
listener
,
atLeastOnce
()).
onIsPlayingChanged
(
anyBoolean
());
verify
(
listener
,
atLeastOnce
()).
onPlayerErrorChanged
(
any
());
...
...
@@ -9572,7 +9510,7 @@ public final class ExoPlayerTest {
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_PLAYBACK_STATE_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_IS_LOADING_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_TRACKS_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_
STATIC
_METADATA_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_
MEDIA
_METADATA_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_PLAY_WHEN_READY_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_IS_PLAYING_CHANGED
)).
isTrue
();
assertThat
(
containsEvent
(
allEvents
,
Player
.
EVENT_PLAYER_ERROR
)).
isTrue
();
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
d47d1ebf
...
...
@@ -375,6 +375,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw
new
UnsupportedOperationException
();
}
@Deprecated
@Override
public
List
<
Metadata
>
getCurrentStaticMetadata
()
{
throw
new
UnsupportedOperationException
();
...
...
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