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
d3cc98d3
authored
Aug 24, 2021
by
samrobinson
Committed by
kim-vde
Aug 25, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Deprecate ExoPlayer AudioComponent.
PiperOrigin-RevId: 392655598
parent
3d5e32dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
55 deletions
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
d3cc98d3
...
@@ -140,78 +140,48 @@ import java.util.List;
...
@@ -140,78 +140,48 @@ import java.util.List;
*/
*/
public
interface
ExoPlayer
extends
Player
{
public
interface
ExoPlayer
extends
Player
{
/** The audio component of an {@link ExoPlayer}. */
/** @deprecated Use the methods in {@link ExoPlayer} instead. */
@Deprecated
interface
AudioComponent
{
interface
AudioComponent
{
/**
/** @deprecated Use {@link ExoPlayer#setAudioAttributes(AudioAttributes, boolean)} instead. */
* Sets the attributes for audio playback, used by the underlying audio track. If not set, the
@Deprecated
* default audio attributes will be used. They are suitable for general media playback.
*
* <p>Setting the audio attributes during playback may introduce a short gap in audio output as
* the audio track is recreated. A new audio session id will also be generated.
*
* <p>If tunneling is enabled by the track selector, the specified audio attributes will be
* ignored, but they will take effect if audio is later played without tunneling.
*
* <p>If the device is running a build before platform API version 21, audio attributes cannot
* be set directly on the underlying audio track. In this case, the usage will be mapped onto an
* equivalent stream type using {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>If audio focus should be handled, the {@link AudioAttributes#usage} must be {@link
* C#USAGE_MEDIA} or {@link C#USAGE_GAME}. Other usages will throw an {@link
* IllegalArgumentException}.
*
* @param audioAttributes The attributes to use for audio playback.
* @param handleAudioFocus True if the player should handle audio focus, false otherwise.
*/
void
setAudioAttributes
(
AudioAttributes
audioAttributes
,
boolean
handleAudioFocus
);
void
setAudioAttributes
(
AudioAttributes
audioAttributes
,
boolean
handleAudioFocus
);
/** Returns the attributes for audio playback. */
/** @deprecated Use {@link Player#getAudioAttributes()} instead. */
@Deprecated
AudioAttributes
getAudioAttributes
();
AudioAttributes
getAudioAttributes
();
/**
/** @deprecated Use {@link ExoPlayer#setAudioSessionId(int)} instead. */
* Sets the ID of the audio session to attach to the underlying {@link
@Deprecated
* android.media.AudioTrack}.
*
* <p>The audio session ID can be generated using {@link C#generateAudioSessionIdV21(Context)}
* for API 21+.
*
* @param audioSessionId The audio session ID, or {@link C#AUDIO_SESSION_ID_UNSET} if it should
* be generated by the framework.
*/
void
setAudioSessionId
(
int
audioSessionId
);
void
setAudioSessionId
(
int
audioSessionId
);
/** Returns the audio session identifier, or {@link C#AUDIO_SESSION_ID_UNSET} if not set. */
/** @deprecated Use {@link ExoPlayer#getAudioSessionId()} instead. */
@Deprecated
int
getAudioSessionId
();
int
getAudioSessionId
();
/** Sets information on an auxiliary audio effect to attach to the underlying audio track. */
/** @deprecated Use {@link ExoPlayer#setAuxEffectInfo(AuxEffectInfo)} instead. */
@Deprecated
void
setAuxEffectInfo
(
AuxEffectInfo
auxEffectInfo
);
void
setAuxEffectInfo
(
AuxEffectInfo
auxEffectInfo
);
/** Detaches any previously attached auxiliary audio effect from the underlying audio track. */
/** @deprecated Use {@link ExoPlayer#clearAuxEffectInfo()} instead. */
@Deprecated
void
clearAuxEffectInfo
();
void
clearAuxEffectInfo
();
/**
/** @deprecated Use {@link Player#setVolume(float)} instead. */
* Sets the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
@Deprecated
*
* @param audioVolume Linear output gain to apply to all audio channels.
*/
void
setVolume
(
float
audioVolume
);
void
setVolume
(
float
audioVolume
);
/**
/** @deprecated Use {@link Player#getVolume()} instead. */
* Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
@Deprecated
*
* @return The linear gain applied to all audio channels.
*/
float
getVolume
();
float
getVolume
();
/**
/** @deprecated Use {@link ExoPlayer#setSkipSilenceEnabled(boolean)} instead. */
* Sets whether skipping silences in the audio stream is enabled.
@Deprecated
*
* @param skipSilenceEnabled Whether skipping silences in the audio stream is enabled.
*/
void
setSkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
void
setSkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
/** Returns whether skipping silences in the audio stream is enabled. */
/** @deprecated Use {@link ExoPlayer#getSkipSilenceEnabled()} instead. */
@Deprecated
boolean
getSkipSilenceEnabled
();
boolean
getSkipSilenceEnabled
();
}
}
...
@@ -944,8 +914,12 @@ public interface ExoPlayer extends Player {
...
@@ -944,8 +914,12 @@ public interface ExoPlayer extends Player {
@Override
@Override
ExoPlaybackException
getPlayerError
();
ExoPlaybackException
getPlayerError
();
/** Returns the component of this player for audio output, or null if audio is not supported. */
/**
* @deprecated Use {@link ExoPlayer}, as the {@link AudioComponent} methods are part of the
* interface.
*/
@Nullable
@Nullable
@Deprecated
AudioComponent
getAudioComponent
();
AudioComponent
getAudioComponent
();
/** Returns the component of this player for video output, or null if video is not supported. */
/** Returns the component of this player for video output, or null if video is not supported. */
...
@@ -953,8 +927,8 @@ public interface ExoPlayer extends Player {
...
@@ -953,8 +927,8 @@ public interface ExoPlayer extends Player {
VideoComponent
getVideoComponent
();
VideoComponent
getVideoComponent
();
/**
/**
* @deprecated Use {@link Player}
instead, as the {@link TextComponent} methods are a part of the
* @deprecated Use {@link Player}
, as the {@link TextComponent} methods are a part of the {@link
*
{@link
Player interface}.
* Player interface}.
*/
*/
@Nullable
@Nullable
@Deprecated
@Deprecated
...
@@ -1113,6 +1087,59 @@ public interface ExoPlayer extends Player {
...
@@ -1113,6 +1087,59 @@ public interface ExoPlayer extends Player {
void
setShuffleOrder
(
ShuffleOrder
shuffleOrder
);
void
setShuffleOrder
(
ShuffleOrder
shuffleOrder
);
/**
/**
* Sets the attributes for audio playback, used by the underlying audio track. If not set, the
* default audio attributes will be used. They are suitable for general media playback.
*
* <p>Setting the audio attributes during playback may introduce a short gap in audio output as
* the audio track is recreated. A new audio session id will also be generated.
*
* <p>If tunneling is enabled by the track selector, the specified audio attributes will be
* ignored, but they will take effect if audio is later played without tunneling.
*
* <p>If the device is running a build before platform API version 21, audio attributes cannot be
* set directly on the underlying audio track. In this case, the usage will be mapped onto an
* equivalent stream type using {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>If audio focus should be handled, the {@link AudioAttributes#usage} must be {@link
* C#USAGE_MEDIA} or {@link C#USAGE_GAME}. Other usages will throw an {@link
* IllegalArgumentException}.
*
* @param audioAttributes The attributes to use for audio playback.
* @param handleAudioFocus True if the player should handle audio focus, false otherwise.
*/
void
setAudioAttributes
(
AudioAttributes
audioAttributes
,
boolean
handleAudioFocus
);
/**
* Sets the ID of the audio session to attach to the underlying {@link android.media.AudioTrack}.
*
* <p>The audio session ID can be generated using {@link C#generateAudioSessionIdV21(Context)} for
* API 21+.
*
* @param audioSessionId The audio session ID, or {@link C#AUDIO_SESSION_ID_UNSET} if it should be
* generated by the framework.
*/
void
setAudioSessionId
(
int
audioSessionId
);
/** Returns the audio session identifier, or {@link C#AUDIO_SESSION_ID_UNSET} if not set. */
int
getAudioSessionId
();
/** Sets information on an auxiliary audio effect to attach to the underlying audio track. */
void
setAuxEffectInfo
(
AuxEffectInfo
auxEffectInfo
);
/** Detaches any previously attached auxiliary audio effect from the underlying audio track. */
void
clearAuxEffectInfo
();
/**
* Sets whether skipping silences in the audio stream is enabled.
*
* @param skipSilenceEnabled Whether skipping silences in the audio stream is enabled.
*/
void
setSkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
/** Returns whether skipping silences in the audio stream is enabled. */
boolean
getSkipSilenceEnabled
();
/**
* Creates a message that can be sent to a {@link PlayerMessage.Target}. By default, the message
* Creates a message that can be sent to a {@link PlayerMessage.Target}. By default, the message
* will be delivered immediately without blocking on the playback thread. The default {@link
* will be delivered immediately without blocking on the playback thread. The default {@link
* PlayerMessage#getType()} is 0 and the default {@link PlayerMessage#getPayload()} is null. If a
* PlayerMessage#getType()} is 0 and the default {@link PlayerMessage#getPayload()} is null. If a
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
d3cc98d3
...
@@ -33,6 +33,7 @@ import com.google.android.exoplayer2.PlayerMessage;
...
@@ -33,6 +33,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.audio.AuxEffectInfo
;
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
;
...
@@ -51,6 +52,7 @@ import java.util.List;
...
@@ -51,6 +52,7 @@ import java.util.List;
public
class
StubExoPlayer
extends
BasePlayer
implements
ExoPlayer
{
public
class
StubExoPlayer
extends
BasePlayer
implements
ExoPlayer
{
@Override
@Override
@Deprecated
public
AudioComponent
getAudioComponent
()
{
public
AudioComponent
getAudioComponent
()
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
@@ -61,11 +63,13 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
...
@@ -61,11 +63,13 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
}
@Override
@Override
@Deprecated
public
TextComponent
getTextComponent
()
{
public
TextComponent
getTextComponent
()
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
@Override
@Override
@Deprecated
public
DeviceComponent
getDeviceComponent
()
{
public
DeviceComponent
getDeviceComponent
()
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
@@ -275,6 +279,41 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
...
@@ -275,6 +279,41 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
}
@Override
@Override
public
void
setAudioAttributes
(
AudioAttributes
audioAttributes
,
boolean
handleAudioFocus
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setAudioSessionId
(
int
audioSessionId
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
int
getAudioSessionId
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setAuxEffectInfo
(
AuxEffectInfo
auxEffectInfo
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
clearAuxEffectInfo
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setSkipSilenceEnabled
(
boolean
skipSilenceEnabled
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
boolean
getSkipSilenceEnabled
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setShuffleModeEnabled
(
boolean
shuffleModeEnabled
)
{
public
void
setShuffleModeEnabled
(
boolean
shuffleModeEnabled
)
{
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