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
96a2c03f
authored
Oct 07, 2021
by
samrobinson
Committed by
bachinger
Oct 07, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add public SimpleExoPlayer methods to ExoPlayer.
PiperOrigin-RevId: 401535981
parent
fc25798a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
70 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
RELEASENOTES.md
View file @
96a2c03f
...
...
@@ -7,6 +7,9 @@
level >= 31. Add methods in
`DefaultMediaCodecRendererFactory`
and
`DefaultRenderersFactory`
to force enable or force disable asynchronous
queueing (
[
6348
](
https://github.com/google/ExoPlayer/issues/6348
)
).
*
Add 12 public method headers to
`ExoPlayer`
that exist in
`SimpleExoPlayer`
, such that all public methods in
`SimpleExoPlayer`
are overrides.
*
Move
`com.google.android.exoplayer2.device.DeviceInfo`
to
`com.google.android.exoplayer2.DeviceInfo`
.
*
Move
`com.google.android.exoplayer2.drm.DecryptionException`
to
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
96a2c03f
...
...
@@ -27,6 +27,7 @@ import androidx.annotation.IntRange;
import
androidx.annotation.Nullable
;
import
androidx.annotation.VisibleForTesting
;
import
com.google.android.exoplayer2.analytics.AnalyticsCollector
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.audio.AudioCapabilities
;
import
com.google.android.exoplayer2.audio.AudioSink
;
...
...
@@ -943,6 +944,23 @@ public interface ExoPlayer extends Player {
*/
void
removeAudioOffloadListener
(
AudioOffloadListener
listener
);
/** Returns the {@link AnalyticsCollector} used for collecting analytics events. */
AnalyticsCollector
getAnalyticsCollector
();
/**
* Adds an {@link AnalyticsListener} to receive analytics events.
*
* @param listener The listener to be added.
*/
void
addAnalyticsListener
(
AnalyticsListener
listener
);
/**
* Removes an {@link AnalyticsListener}.
*
* @param listener The listener to be removed.
*/
void
removeAnalyticsListener
(
AnalyticsListener
listener
);
/** Returns the number of renderers. */
int
getRendererCount
();
...
...
@@ -1268,6 +1286,77 @@ public interface ExoPlayer extends Player {
*/
boolean
getPauseAtEndOfMediaItems
();
/** Returns the audio format currently being played, or null if no audio is being played. */
@Nullable
Format
getAudioFormat
();
/** Returns the video format currently being played, or null if no video is being played. */
@Nullable
Format
getVideoFormat
();
/** Returns {@link DecoderCounters} for audio, or null if no audio is being played. */
@Nullable
DecoderCounters
getAudioDecoderCounters
();
/** Returns {@link DecoderCounters} for video, or null if no video is being played. */
@Nullable
DecoderCounters
getVideoDecoderCounters
();
/**
* Sets whether the player should pause automatically when audio is rerouted from a headset to
* device speakers. See the <a
* href="https://developer.android.com/guide/topics/media-apps/volume-and-earphones#becoming-noisy">audio
* becoming noisy</a> documentation for more information.
*
* @param handleAudioBecomingNoisy Whether the player should pause automatically when audio is
* rerouted from a headset to device speakers.
*/
void
setHandleAudioBecomingNoisy
(
boolean
handleAudioBecomingNoisy
);
/** @deprecated Use {@link #setWakeMode(int)} instead. */
@Deprecated
void
setHandleWakeLock
(
boolean
handleWakeLock
);
/**
* Sets how the player should keep the device awake for playback when the screen is off.
*
* <p>Enabling this feature requires the {@link android.Manifest.permission#WAKE_LOCK} permission.
* It should be used together with a foreground {@link android.app.Service} for use cases where
* playback occurs and the screen is off (e.g. background audio playback). It is not useful when
* the screen will be kept on during playback (e.g. foreground video playback).
*
* <p>When enabled, the locks ({@link android.os.PowerManager.WakeLock} / {@link
* android.net.wifi.WifiManager.WifiLock}) will be held whenever the player is in the {@link
* #STATE_READY} or {@link #STATE_BUFFERING} states with {@code playWhenReady = true}. The locks
* held depends on the specified {@link C.WakeMode}.
*
* @param wakeMode The {@link C.WakeMode} option to keep the device awake during playback.
*/
void
setWakeMode
(
@C
.
WakeMode
int
wakeMode
);
/**
* Sets a {@link PriorityTaskManager}, or null to clear a previously set priority task manager.
*
* <p>The priority {@link C#PRIORITY_PLAYBACK} will be set while the player is loading.
*
* @param priorityTaskManager The {@link PriorityTaskManager}, or null to clear a previously set
* priority task manager.
*/
void
setPriorityTaskManager
(
@Nullable
PriorityTaskManager
priorityTaskManager
);
/**
* Sets whether the player should throw an {@link IllegalStateException} when methods are called
* from a thread other than the one associated with {@link #getApplicationLooper()}.
*
* <p>The default is {@code true} and this method will be removed in the future.
*
* @param throwsWhenUsingWrongThread Whether to throw when methods are called from a wrong thread.
* @deprecated Disabling the enforcement can result in hard-to-detect bugs. Do not use this method
* except to ease the transition while wrong thread access problems are fixed.
*/
@Deprecated
void
setThrowsWhenUsingWrongThread
(
boolean
throwsWhenUsingWrongThread
);
/**
* Sets whether audio offload scheduling is enabled. If enabled, ExoPlayer's main loop will run as
* rarely as possible when playing an audio stream using audio offload.
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
96a2c03f
...
...
@@ -906,41 +906,25 @@ public class SimpleExoPlayer extends BasePlayer
notifySkipSilenceEnabledChanged
();
}
/** Returns the {@link AnalyticsCollector} used for collecting analytics events. */
@Override
public
AnalyticsCollector
getAnalyticsCollector
()
{
return
analyticsCollector
;
}
/**
* Adds an {@link AnalyticsListener} to receive analytics events.
*
* @param listener The listener to be added.
*/
@Override
public
void
addAnalyticsListener
(
AnalyticsListener
listener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
Assertions
.
checkNotNull
(
listener
);
analyticsCollector
.
addListener
(
listener
);
}
/**
* Removes an {@link AnalyticsListener}.
*
* @param listener The listener to be removed.
*/
@Override
public
void
removeAnalyticsListener
(
AnalyticsListener
listener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
analyticsCollector
.
removeListener
(
listener
);
}
/**
* Sets whether the player should pause automatically when audio is rerouted from a headset to
* device speakers. See the <a
* href="https://developer.android.com/guide/topics/media-apps/volume-and-earphones#becoming-noisy">audio
* becoming noisy</a> documentation for more information.
*
* @param handleAudioBecomingNoisy Whether the player should pause automatically when audio is
* rerouted from a headset to device speakers.
*/
@Override
public
void
setHandleAudioBecomingNoisy
(
boolean
handleAudioBecomingNoisy
)
{
verifyApplicationThread
();
if
(
playerReleased
)
{
...
...
@@ -949,14 +933,7 @@ public class SimpleExoPlayer extends BasePlayer
audioBecomingNoisyManager
.
setEnabled
(
handleAudioBecomingNoisy
);
}
/**
* Sets a {@link PriorityTaskManager}, or null to clear a previously set priority task manager.
*
* <p>The priority {@link C#PRIORITY_PLAYBACK} will be set while the player is loading.
*
* @param priorityTaskManager The {@link PriorityTaskManager}, or null to clear a previously set
* priority task manager.
*/
@Override
public
void
setPriorityTaskManager
(
@Nullable
PriorityTaskManager
priorityTaskManager
)
{
verifyApplicationThread
();
if
(
Util
.
areEqual
(
this
.
priorityTaskManager
,
priorityTaskManager
))
{
...
...
@@ -974,25 +951,25 @@ public class SimpleExoPlayer extends BasePlayer
this
.
priorityTaskManager
=
priorityTaskManager
;
}
/** Returns the video format currently being played, or null if no video is being played. */
@Override
@Nullable
public
Format
getVideoFormat
()
{
return
videoFormat
;
}
/** Returns the audio format currently being played, or null if no audio is being played. */
@Override
@Nullable
public
Format
getAudioFormat
()
{
return
audioFormat
;
}
/** Returns {@link DecoderCounters} for video, or null if no video is being played. */
@Override
@Nullable
public
DecoderCounters
getVideoDecoderCounters
()
{
return
videoDecoderCounters
;
}
/** Returns {@link DecoderCounters} for audio, or null if no audio is being played. */
@Override
@Nullable
public
DecoderCounters
getAudioDecoderCounters
()
{
return
audioDecoderCounters
;
...
...
@@ -1561,39 +1538,13 @@ public class SimpleExoPlayer extends BasePlayer
return
player
.
getContentBufferedPosition
();
}
/**
* Sets whether the player should use a {@link android.os.PowerManager.WakeLock} to ensure the
* device stays awake for playback, even when the screen is off.
*
* <p>Enabling this feature requires the {@link android.Manifest.permission#WAKE_LOCK} permission.
* It should be used together with a foreground {@link android.app.Service} for use cases where
* playback can occur when the screen is off (e.g. background audio playback). It is not useful if
* the screen will always be on during playback (e.g. foreground video playback).
*
* @param handleWakeLock Whether the player should use a {@link android.os.PowerManager.WakeLock}
* to ensure the device stays awake for playback, even when the screen is off.
* @deprecated Use {@link #setWakeMode(int)} instead.
*/
@Deprecated
@Override
public
void
setHandleWakeLock
(
boolean
handleWakeLock
)
{
setWakeMode
(
handleWakeLock
?
C
.
WAKE_MODE_LOCAL
:
C
.
WAKE_MODE_NONE
);
}
/**
* Sets how the player should keep the device awake for playback when the screen is off.
*
* <p>Enabling this feature requires the {@link android.Manifest.permission#WAKE_LOCK} permission.
* It should be used together with a foreground {@link android.app.Service} for use cases where
* playback occurs and the screen is off (e.g. background audio playback). It is not useful when
* the screen will be kept on during playback (e.g. foreground video playback).
*
* <p>When enabled, the locks ({@link android.os.PowerManager.WakeLock} / {@link
* android.net.wifi.WifiManager.WifiLock}) will be held whenever the player is in the {@link
* #STATE_READY} or {@link #STATE_BUFFERING} states with {@code playWhenReady = true}. The locks
* held depends on the specified {@link C.WakeMode}.
*
* @param wakeMode The {@link C.WakeMode} option to keep the device awake during playback.
*/
@Override
public
void
setWakeMode
(
@C
.
WakeMode
int
wakeMode
)
{
verifyApplicationThread
();
switch
(
wakeMode
)
{
...
...
@@ -1656,17 +1607,8 @@ public class SimpleExoPlayer extends BasePlayer
streamVolumeManager
.
setMuted
(
muted
);
}
/**
* Sets whether the player should throw an {@link IllegalStateException} when methods are called
* from a thread other than the one associated with {@link #getApplicationLooper()}.
*
* <p>The default is {@code true} and this method will be removed in the future.
*
* @param throwsWhenUsingWrongThread Whether to throw when methods are called from a wrong thread.
* @deprecated Disabling the enforcement can result in hard-to-detect bugs. Do not use this method
* except to ease the transition while wrong thread access problems are fixed.
*/
@Deprecated
@Override
public
void
setThrowsWhenUsingWrongThread
(
boolean
throwsWhenUsingWrongThread
)
{
this
.
throwsWhenUsingWrongThread
=
throwsWhenUsingWrongThread
;
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
96a2c03f
...
...
@@ -26,6 +26,7 @@ import com.google.android.exoplayer2.BasePlayer;
import
com.google.android.exoplayer2.DeviceInfo
;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.MediaMetadata
;
import
com.google.android.exoplayer2.PlaybackParameters
;
...
...
@@ -34,8 +35,11 @@ import com.google.android.exoplayer2.PlayerMessage;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.TracksInfo
;
import
com.google.android.exoplayer2.analytics.AnalyticsCollector
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.audio.AuxEffectInfo
;
import
com.google.android.exoplayer2.decoder.DecoderCounters
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
...
...
@@ -44,6 +48,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import
com.google.android.exoplayer2.trackselection.TrackSelectionParameters
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
import
com.google.android.exoplayer2.util.Clock
;
import
com.google.android.exoplayer2.util.PriorityTaskManager
;
import
com.google.android.exoplayer2.video.VideoFrameMetadataListener
;
import
com.google.android.exoplayer2.video.VideoSize
;
import
com.google.android.exoplayer2.video.spherical.CameraMotionListener
;
...
...
@@ -129,6 +134,21 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
@Override
public
AnalyticsCollector
getAnalyticsCollector
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
addAnalyticsListener
(
AnalyticsListener
listener
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
removeAnalyticsListener
(
AnalyticsListener
listener
)
{
throw
new
UnsupportedOperationException
();
}
@Override
@State
public
int
getPlaybackState
()
{
throw
new
UnsupportedOperationException
();
...
...
@@ -674,6 +694,57 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw
new
UnsupportedOperationException
();
}
@Nullable
@Override
public
Format
getAudioFormat
()
{
throw
new
UnsupportedOperationException
();
}
@Nullable
@Override
public
Format
getVideoFormat
()
{
throw
new
UnsupportedOperationException
();
}
@Nullable
@Override
public
DecoderCounters
getAudioDecoderCounters
()
{
throw
new
UnsupportedOperationException
();
}
@Nullable
@Override
public
DecoderCounters
getVideoDecoderCounters
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setHandleAudioBecomingNoisy
(
boolean
handleAudioBecomingNoisy
)
{
throw
new
UnsupportedOperationException
();
}
@Deprecated
@Override
public
void
setHandleWakeLock
(
boolean
handleWakeLock
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setWakeMode
(
int
wakeMode
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setPriorityTaskManager
(
@Nullable
PriorityTaskManager
priorityTaskManager
)
{
throw
new
UnsupportedOperationException
();
}
@Deprecated
@Override
public
void
setThrowsWhenUsingWrongThread
(
boolean
throwsWhenUsingWrongThread
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
experimentalSetOffloadSchedulingEnabled
(
boolean
offloadSchedulingEnabled
)
{
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