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
54f3dfb4
authored
Apr 14, 2021
by
krocard
Committed by
Andrew Lewis
Apr 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move DeviceComponent in ExoPlayer
PiperOrigin-RevId: 368437660
parent
5ae84ab5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
194 additions
and
60 deletions
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/common/src/main/java/com/google/android/exoplayer2/device/DeviceListener.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
54f3dfb4
...
@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.PlaybackParameters;
...
@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.PlaybackParameters;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.device.DeviceInfo
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.source.TrackGroup
;
import
com.google.android.exoplayer2.source.TrackGroup
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
...
@@ -282,13 +283,6 @@ public final class CastPlayer extends BasePlayer {
...
@@ -282,13 +283,6 @@ public final class CastPlayer extends BasePlayer {
}
}
@Override
@Override
@Nullable
public
DeviceComponent
getDeviceComponent
()
{
// TODO(b/151792305): Implement the component.
return
null
;
}
@Override
public
Looper
getApplicationLooper
()
{
public
Looper
getApplicationLooper
()
{
return
Looper
.
getMainLooper
();
return
Looper
.
getMainLooper
();
}
}
...
@@ -665,6 +659,40 @@ public final class CastPlayer extends BasePlayer {
...
@@ -665,6 +659,40 @@ public final class CastPlayer extends BasePlayer {
return
ImmutableList
.
of
();
return
ImmutableList
.
of
();
}
}
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
@Override
public
DeviceInfo
getDeviceInfo
()
{
return
DeviceInfo
.
UNKNOWN
;
}
/** This method is not supported and always returns {@code 0}. */
@Override
public
int
getDeviceVolume
()
{
return
0
;
}
/** This method is not supported and always returns {@code false}. */
@Override
public
boolean
isDeviceMuted
()
{
return
false
;
}
/** This method is not supported and does nothing. */
@Override
public
void
setDeviceVolume
(
int
volume
)
{}
/** This method is not supported and does nothing. */
@Override
public
void
increaseDeviceVolume
()
{}
/** This method is not supported and does nothing. */
@Override
public
void
decreaseDeviceVolume
()
{}
/** This method is not supported and does nothing. */
@Override
public
void
setDeviceMuted
(
boolean
muted
)
{}
// Internal methods.
// Internal methods.
// Call deprecated callbacks.
// Call deprecated callbacks.
...
...
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
54f3dfb4
...
@@ -206,51 +206,6 @@ public interface Player {
...
@@ -206,51 +206,6 @@ public interface Player {
void
clearVideoTextureView
(
@Nullable
TextureView
textureView
);
void
clearVideoTextureView
(
@Nullable
TextureView
textureView
);
}
}
/** The device component of a {@link Player}. */
interface
DeviceComponent
{
/** Adds a listener to receive device events. */
void
addDeviceListener
(
DeviceListener
listener
);
/** Removes a listener of device events. */
void
removeDeviceListener
(
DeviceListener
listener
);
/** Gets the device information. */
DeviceInfo
getDeviceInfo
();
/**
* Gets the current volume of the device.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_LOCAL local playback}, the volume
* returned by this method varies according to the current {@link C.StreamType stream type}. The
* stream type is determined by {@link AudioAttributes#usage} which can be converted to stream
* type with {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_REMOTE remote playback}, the volume of
* the remote device is returned.
*/
int
getDeviceVolume
();
/** Gets whether the device is muted or not. */
boolean
isDeviceMuted
();
/**
* Sets the volume of the device.
*
* @param volume The volume to set.
*/
void
setDeviceVolume
(
int
volume
);
/** Increases the volume of the device. */
void
increaseDeviceVolume
();
/** Decreases the volume of the device. */
void
decreaseDeviceVolume
();
/** Sets the mute state of the device. */
void
setDeviceMuted
(
boolean
muted
);
}
/**
/**
* Listener of changes in player state.
* Listener of changes in player state.
*
*
...
@@ -1130,10 +1085,6 @@ public interface Player {
...
@@ -1130,10 +1085,6 @@ public interface Player {
@Nullable
@Nullable
VideoComponent
getVideoComponent
();
VideoComponent
getVideoComponent
();
/** Returns the component of this player for playback device, or null if it's not supported. */
@Nullable
DeviceComponent
getDeviceComponent
();
/**
/**
* Returns the {@link Looper} associated with the application thread that's used to access the
* Returns the {@link Looper} associated with the application thread that's used to access the
* player and on which player events are received.
* player and on which player events are received.
...
@@ -1810,4 +1761,39 @@ public interface Player {
...
@@ -1810,4 +1761,39 @@ public interface Player {
/** Returns the current {@link Cue Cues}. This list may be empty. */
/** Returns the current {@link Cue Cues}. This list may be empty. */
List
<
Cue
>
getCurrentCues
();
List
<
Cue
>
getCurrentCues
();
/** Gets the device information. */
DeviceInfo
getDeviceInfo
();
/**
* Gets the current volume of the device.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_LOCAL local playback}, the volume returned
* by this method varies according to the current {@link C.StreamType stream type}. The stream
* type is determined by {@link AudioAttributes#usage} which can be converted to stream type with
* {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_REMOTE remote playback}, the volume of the
* remote device is returned.
*/
int
getDeviceVolume
();
/** Gets whether the device is muted or not. */
boolean
isDeviceMuted
();
/**
* Sets the volume of the device.
*
* @param volume The volume to set.
*/
void
setDeviceVolume
(
int
volume
);
/** Increases the volume of the device. */
void
increaseDeviceVolume
();
/** Decreases the volume of the device. */
void
decreaseDeviceVolume
();
/** Sets the mute state of the device. */
void
setDeviceMuted
(
boolean
muted
);
}
}
library/common/src/main/java/com/google/android/exoplayer2/device/DeviceListener.java
View file @
54f3dfb4
...
@@ -15,9 +15,7 @@
...
@@ -15,9 +15,7 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
device
;
package
com
.
google
.
android
.
exoplayer2
.
device
;
import
com.google.android.exoplayer2.Player
;
/** A listener for changes of {@link DeviceInfo} or device volume. */
/** A listener for changes of {@link Player.DeviceComponent}. */
public
interface
DeviceListener
{
public
interface
DeviceListener
{
/** Called when the device information changes. */
/** Called when the device information changes. */
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
54f3dfb4
...
@@ -28,6 +28,8 @@ import com.google.android.exoplayer2.audio.AudioSink;
...
@@ -28,6 +28,8 @@ import com.google.android.exoplayer2.audio.AudioSink;
import
com.google.android.exoplayer2.audio.AuxEffectInfo
;
import
com.google.android.exoplayer2.audio.AuxEffectInfo
;
import
com.google.android.exoplayer2.audio.DefaultAudioSink
;
import
com.google.android.exoplayer2.audio.DefaultAudioSink
;
import
com.google.android.exoplayer2.audio.MediaCodecAudioRenderer
;
import
com.google.android.exoplayer2.audio.MediaCodecAudioRenderer
;
import
com.google.android.exoplayer2.device.DeviceInfo
;
import
com.google.android.exoplayer2.device.DeviceListener
;
import
com.google.android.exoplayer2.metadata.MetadataOutput
;
import
com.google.android.exoplayer2.metadata.MetadataOutput
;
import
com.google.android.exoplayer2.metadata.MetadataRenderer
;
import
com.google.android.exoplayer2.metadata.MetadataRenderer
;
import
com.google.android.exoplayer2.source.DefaultMediaSourceFactory
;
import
com.google.android.exoplayer2.source.DefaultMediaSourceFactory
;
...
@@ -260,6 +262,51 @@ public interface ExoPlayer extends Player {
...
@@ -260,6 +262,51 @@ public interface ExoPlayer extends Player {
void
removeMetadataOutput
(
MetadataOutput
output
);
void
removeMetadataOutput
(
MetadataOutput
output
);
}
}
/** The device component of an {@link ExoPlayer}. */
interface
DeviceComponent
{
/** Adds a listener to receive device events. */
void
addDeviceListener
(
DeviceListener
listener
);
/** Removes a listener of device events. */
void
removeDeviceListener
(
DeviceListener
listener
);
/** Gets the device information. */
DeviceInfo
getDeviceInfo
();
/**
* Gets the current volume of the device.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_LOCAL local playback}, the volume
* returned by this method varies according to the current {@link C.StreamType stream type}. The
* stream type is determined by {@link AudioAttributes#usage} which can be converted to stream
* type with {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>For devices with {@link DeviceInfo#PLAYBACK_TYPE_REMOTE remote playback}, the volume of
* the remote device is returned.
*/
int
getDeviceVolume
();
/** Gets whether the device is muted or not. */
boolean
isDeviceMuted
();
/**
* Sets the volume of the device.
*
* @param volume The volume to set.
*/
void
setDeviceVolume
(
int
volume
);
/** Increases the volume of the device. */
void
increaseDeviceVolume
();
/** Decreases the volume of the device. */
void
decreaseDeviceVolume
();
/** Sets the mute state of the device. */
void
setDeviceMuted
(
boolean
muted
);
}
/**
/**
* The default timeout for calls to {@link #release} and {@link #setForegroundMode}, in
* The default timeout for calls to {@link #release} and {@link #setForegroundMode}, in
* milliseconds.
* milliseconds.
...
@@ -613,6 +660,10 @@ public interface ExoPlayer extends Player {
...
@@ -613,6 +660,10 @@ public interface ExoPlayer extends Player {
@Nullable
@Nullable
MetadataComponent
getMetadataComponent
();
MetadataComponent
getMetadataComponent
();
/** Returns the component of this player for playback device, or null if it's not supported. */
@Nullable
DeviceComponent
getDeviceComponent
();
/**
/**
* Adds a listener to receive audio offload events.
* Adds a listener to receive audio offload events.
*
*
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
54f3dfb4
...
@@ -29,6 +29,7 @@ import androidx.annotation.Nullable;
...
@@ -29,6 +29,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.PlayerMessage.Target
;
import
com.google.android.exoplayer2.PlayerMessage.Target
;
import
com.google.android.exoplayer2.analytics.AnalyticsCollector
;
import
com.google.android.exoplayer2.analytics.AnalyticsCollector
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.device.DeviceInfo
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
...
@@ -1009,6 +1010,40 @@ import java.util.concurrent.CopyOnWriteArraySet;
...
@@ -1009,6 +1010,40 @@ import java.util.concurrent.CopyOnWriteArraySet;
return
ImmutableList
.
of
();
return
ImmutableList
.
of
();
}
}
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
@Override
public
DeviceInfo
getDeviceInfo
()
{
return
DeviceInfo
.
UNKNOWN
;
}
/** This method is not supported and always returns {@code 0}. */
@Override
public
int
getDeviceVolume
()
{
return
0
;
}
/** This method is not supported and always returns {@link false}. */
@Override
public
boolean
isDeviceMuted
()
{
return
false
;
}
/** This method is not supported and does nothing. */
@Override
public
void
setDeviceVolume
(
int
volume
)
{}
/** This method is not supported and does nothing. */
@Override
public
void
increaseDeviceVolume
()
{}
/** This method is not supported and does nothing. */
@Override
public
void
decreaseDeviceVolume
()
{}
/** This method is not supported and does nothing. */
@Override
public
void
setDeviceMuted
(
boolean
muted
)
{}
private
int
getCurrentWindowIndexInternal
()
{
private
int
getCurrentWindowIndexInternal
()
{
if
(
playbackInfo
.
timeline
.
isEmpty
())
{
if
(
playbackInfo
.
timeline
.
isEmpty
())
{
return
maskingWindowIndex
;
return
maskingWindowIndex
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
54f3dfb4
...
@@ -82,7 +82,7 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -82,7 +82,7 @@ public class SimpleExoPlayer extends BasePlayer
Player
.
VideoComponent
,
Player
.
VideoComponent
,
ExoPlayer
.
TextComponent
,
ExoPlayer
.
TextComponent
,
ExoPlayer
.
MetadataComponent
,
ExoPlayer
.
MetadataComponent
,
Player
.
DeviceComponent
{
Exo
Player
.
DeviceComponent
{
/** The default timeout for detaching a surface from the player, in milliseconds. */
/** The default timeout for detaching a surface from the player, in milliseconds. */
public
static
final
long
DEFAULT_DETACH_SURFACE_TIMEOUT_MS
=
2_000
;
public
static
final
long
DEFAULT_DETACH_SURFACE_TIMEOUT_MS
=
2_000
;
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
54f3dfb4
...
@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.PlayerMessage;
...
@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.PlayerMessage;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.device.DeviceInfo
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
...
@@ -445,6 +446,41 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
...
@@ -445,6 +446,41 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
}
@Override
@Override
public
DeviceInfo
getDeviceInfo
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
int
getDeviceVolume
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
boolean
isDeviceMuted
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setDeviceVolume
(
int
volume
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
increaseDeviceVolume
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
decreaseDeviceVolume
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setDeviceMuted
(
boolean
muted
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setForegroundMode
(
boolean
foregroundMode
)
{
public
void
setForegroundMode
(
boolean
foregroundMode
)
{
throw
new
UnsupportedOperationException
();
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