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
7f19b885
authored
Nov 18, 2019
by
olly
Committed by
Oliver Woodman
Nov 19, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make some listener methods default
PiperOrigin-RevId: 281050034
parent
6b03ce8f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
95 deletions
library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionEventListener.java
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceEventListener.java
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java
library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaSource.java
library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionEventListener.java
View file @
7f19b885
...
...
@@ -24,7 +24,7 @@ public interface DefaultDrmSessionEventListener {
default
void
onDrmSessionAcquired
()
{}
/** Called each time keys are loaded. */
void
onDrmKeysLoaded
();
default
void
onDrmKeysLoaded
()
{}
/**
* Called when a drm error occurs.
...
...
@@ -38,13 +38,13 @@ public interface DefaultDrmSessionEventListener {
*
* @param error The corresponding exception.
*/
void
onDrmSessionManagerError
(
Exception
error
);
default
void
onDrmSessionManagerError
(
Exception
error
)
{}
/** Called each time offline keys are restored. */
void
onDrmKeysRestored
();
default
void
onDrmKeysRestored
()
{}
/** Called each time offline keys are removed. */
void
onDrmKeysRemoved
();
default
void
onDrmKeysRemoved
()
{}
/** Called each time a drm session is released. */
default
void
onDrmSessionReleased
()
{}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceEventListener.java
View file @
7f19b885
...
...
@@ -15,78 +15,9 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
source
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
import
java.io.IOException
;
/**
*
A {@link MediaSourceEventListener} allowing selective overrides. All methods are implemented
as
*
no-op
s.
*
@deprecated Use {@link MediaSourceEventListener} interface directly for selective overrides
as
*
all methods are implemented as no-op default method
s.
*/
public
abstract
class
DefaultMediaSourceEventListener
implements
MediaSourceEventListener
{
@Override
public
void
onMediaPeriodCreated
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{
// Do nothing.
}
@Override
public
void
onMediaPeriodReleased
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{
// Do nothing.
}
@Override
public
void
onLoadStarted
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
{
// Do nothing.
}
@Override
public
void
onLoadCompleted
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
{
// Do nothing.
}
@Override
public
void
onLoadCanceled
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
{
// Do nothing.
}
@Override
public
void
onLoadError
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
,
IOException
error
,
boolean
wasCanceled
)
{
// Do nothing.
}
@Override
public
void
onReadingStarted
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{
// Do nothing.
}
@Override
public
void
onUpstreamDiscarded
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
{
// Do nothing.
}
@Override
public
void
onDownstreamFormatChanged
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
{
// Do nothing.
}
}
@Deprecated
public
abstract
class
DefaultMediaSourceEventListener
implements
MediaSourceEventListener
{}
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
View file @
7f19b885
...
...
@@ -365,7 +365,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
}
@Deprecated
private
static
final
class
EventListenerWrapper
extends
Default
MediaSourceEventListener
{
private
static
final
class
EventListenerWrapper
implements
MediaSourceEventListener
{
private
final
EventListener
eventListener
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java
View file @
7f19b885
...
...
@@ -164,7 +164,7 @@ public interface MediaSourceEventListener {
* @param windowIndex The window index in the timeline this media period belongs to.
* @param mediaPeriodId The {@link MediaPeriodId} of the created media period.
*/
void
onMediaPeriodCreated
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
);
default
void
onMediaPeriodCreated
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{}
/**
* Called when a media period is released by the media source.
...
...
@@ -172,7 +172,7 @@ public interface MediaSourceEventListener {
* @param windowIndex The window index in the timeline this media period belongs to.
* @param mediaPeriodId The {@link MediaPeriodId} of the released media period.
*/
void
onMediaPeriodReleased
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
);
default
void
onMediaPeriodReleased
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{}
/**
* Called when a load begins.
...
...
@@ -185,11 +185,11 @@ public interface MediaSourceEventListener {
* LoadEventInfo#responseHeaders} will be empty.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void
onLoadStarted
(
default
void
onLoadStarted
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
;
MediaLoadData
mediaLoadData
)
{}
/**
* Called when a load ends.
...
...
@@ -203,11 +203,11 @@ public interface MediaSourceEventListener {
* event.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void
onLoadCompleted
(
default
void
onLoadCompleted
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
;
MediaLoadData
mediaLoadData
)
{}
/**
* Called when a load is canceled.
...
...
@@ -221,11 +221,11 @@ public interface MediaSourceEventListener {
* event.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void
onLoadCanceled
(
default
void
onLoadCanceled
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
)
;
MediaLoadData
mediaLoadData
)
{}
/**
* Called when a load error occurs.
...
...
@@ -252,13 +252,13 @@ public interface MediaSourceEventListener {
* @param error The load error.
* @param wasCanceled Whether the load was canceled as a result of the error.
*/
void
onLoadError
(
default
void
onLoadError
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
LoadEventInfo
loadEventInfo
,
MediaLoadData
mediaLoadData
,
IOException
error
,
boolean
wasCanceled
)
;
boolean
wasCanceled
)
{}
/**
* Called when a media period is first being read from.
...
...
@@ -266,7 +266,7 @@ public interface MediaSourceEventListener {
* @param windowIndex The window index in the timeline this media period belongs to.
* @param mediaPeriodId The {@link MediaPeriodId} of the media period being read from.
*/
void
onReadingStarted
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
);
default
void
onReadingStarted
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
)
{}
/**
* Called when data is removed from the back of a media buffer, typically so that it can be
...
...
@@ -276,8 +276,8 @@ public interface MediaSourceEventListener {
* @param mediaPeriodId The {@link MediaPeriodId} the media belongs to.
* @param mediaLoadData The {@link MediaLoadData} defining the media being discarded.
*/
void
onUpstreamDiscarded
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
;
default
void
onUpstreamDiscarded
(
int
windowIndex
,
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
{}
/**
* Called when a downstream format change occurs (i.e. when the format of the media being read
...
...
@@ -287,8 +287,8 @@ public interface MediaSourceEventListener {
* @param mediaPeriodId The {@link MediaPeriodId} the media belongs to.
* @param mediaLoadData The {@link MediaLoadData} defining the newly selected downstream data.
*/
void
onDownstreamFormatChanged
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
;
default
void
onDownstreamFormatChanged
(
int
windowIndex
,
@Nullable
MediaPeriodId
mediaPeriodId
,
MediaLoadData
mediaLoadData
)
{}
/** Dispatches events to {@link MediaSourceEventListener}s. */
final
class
EventDispatcher
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaSource.java
View file @
7f19b885
...
...
@@ -347,7 +347,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
*/
@Deprecated
@SuppressWarnings
(
"deprecation"
)
private
static
final
class
EventListenerWrapper
extends
Default
MediaSourceEventListener
{
private
static
final
class
EventListenerWrapper
implements
MediaSourceEventListener
{
private
final
EventListener
eventListener
;
private
final
int
eventSourceId
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
View file @
7f19b885
...
...
@@ -555,7 +555,7 @@ public final class ClippingMediaSourceTest {
()
->
clippingMediaSource
.
addEventListener
(
new
Handler
(),
new
Default
MediaSourceEventListener
()
{
new
MediaSourceEventListener
()
{
@Override
public
void
onDownstreamFormatChanged
(
int
windowIndex
,
...
...
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