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
5ae84ab5
authored
Apr 14, 2021
by
krocard
Committed by
Andrew Lewis
Apr 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move TextComponent to ExoPlayer
PiperOrigin-RevId: 368428647
parent
bd654279
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 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/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
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.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 @
5ae84ab5
...
@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.audio.AudioAttributes;
...
@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.audio.AudioAttributes;
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
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.trackselection.TrackSelection
;
import
com.google.android.exoplayer2.trackselection.TrackSelection
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
...
@@ -55,7 +56,7 @@ import com.google.android.gms.cast.framework.media.RemoteMediaClient;
...
@@ -55,7 +56,7 @@ import com.google.android.gms.cast.framework.media.RemoteMediaClient;
import
com.google.android.gms.cast.framework.media.RemoteMediaClient.MediaChannelResult
;
import
com.google.android.gms.cast.framework.media.RemoteMediaClient.MediaChannelResult
;
import
com.google.android.gms.common.api.PendingResult
;
import
com.google.android.gms.common.api.PendingResult
;
import
com.google.android.gms.common.api.ResultCallback
;
import
com.google.android.gms.common.api.ResultCallback
;
import
java.util.Collections
;
import
com.google.common.collect.ImmutableList
;
import
java.util.List
;
import
java.util.List
;
import
org.checkerframework.checker.nullness.qual.RequiresNonNull
;
import
org.checkerframework.checker.nullness.qual.RequiresNonNull
;
...
@@ -282,12 +283,6 @@ public final class CastPlayer extends BasePlayer {
...
@@ -282,12 +283,6 @@ public final class CastPlayer extends BasePlayer {
@Override
@Override
@Nullable
@Nullable
public
TextComponent
getTextComponent
()
{
return
null
;
}
@Override
@Nullable
public
DeviceComponent
getDeviceComponent
()
{
public
DeviceComponent
getDeviceComponent
()
{
// TODO(b/151792305): Implement the component.
// TODO(b/151792305): Implement the component.
return
null
;
return
null
;
...
@@ -562,9 +557,9 @@ public final class CastPlayer extends BasePlayer {
...
@@ -562,9 +557,9 @@ public final class CastPlayer extends BasePlayer {
}
}
@Override
@Override
public
List
<
Metadata
>
getCurrentStaticMetadata
()
{
public
Immutable
List
<
Metadata
>
getCurrentStaticMetadata
()
{
// CastPlayer does not currently support metadata.
// CastPlayer does not currently support metadata.
return
Collections
.
emptyList
();
return
ImmutableList
.
of
();
}
}
@Override
@Override
...
@@ -664,6 +659,12 @@ public final class CastPlayer extends BasePlayer {
...
@@ -664,6 +659,12 @@ public final class CastPlayer extends BasePlayer {
return
1
;
return
1
;
}
}
/** This method is not supported and returns an empty list. */
@Override
public
ImmutableList
<
Cue
>
getCurrentCues
()
{
return
ImmutableList
.
of
();
}
// Internal methods.
// Internal methods.
// Call deprecated callbacks.
// Call deprecated callbacks.
...
...
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
5ae84ab5
...
@@ -206,27 +206,6 @@ public interface Player {
...
@@ -206,27 +206,6 @@ public interface Player {
void
clearVideoTextureView
(
@Nullable
TextureView
textureView
);
void
clearVideoTextureView
(
@Nullable
TextureView
textureView
);
}
}
/** The text component of a {@link Player}. */
interface
TextComponent
{
/**
* Registers an output to receive text events.
*
* @param listener The output to register.
*/
void
addTextOutput
(
TextOutput
listener
);
/**
* Removes a text output.
*
* @param listener The output to remove.
*/
void
removeTextOutput
(
TextOutput
listener
);
/** Returns the current {@link Cue Cues}. This list may be empty. */
List
<
Cue
>
getCurrentCues
();
}
/** The device component of a {@link Player}. */
/** The device component of a {@link Player}. */
interface
DeviceComponent
{
interface
DeviceComponent
{
...
@@ -1151,10 +1130,6 @@ public interface Player {
...
@@ -1151,10 +1130,6 @@ public interface Player {
@Nullable
@Nullable
VideoComponent
getVideoComponent
();
VideoComponent
getVideoComponent
();
/** Returns the component of this player for text output, or null if text is not supported. */
@Nullable
TextComponent
getTextComponent
();
/** Returns the component of this player for playback device, or null if it's not supported. */
/** Returns the component of this player for playback device, or null if it's not supported. */
@Nullable
@Nullable
DeviceComponent
getDeviceComponent
();
DeviceComponent
getDeviceComponent
();
...
@@ -1832,4 +1807,7 @@ public interface Player {
...
@@ -1832,4 +1807,7 @@ public interface Player {
* @return The linear gain applied to all audio channels.
* @return The linear gain applied to all audio channels.
*/
*/
float
getVolume
();
float
getVolume
();
/** Returns the current {@link Cue Cues}. This list may be empty. */
List
<
Cue
>
getCurrentCues
();
}
}
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
5ae84ab5
...
@@ -34,6 +34,8 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
...
@@ -34,6 +34,8 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.MediaSourceFactory
;
import
com.google.android.exoplayer2.source.MediaSourceFactory
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.TextOutput
;
import
com.google.android.exoplayer2.text.TextRenderer
;
import
com.google.android.exoplayer2.text.TextRenderer
;
import
com.google.android.exoplayer2.trackselection.DefaultTrackSelector
;
import
com.google.android.exoplayer2.trackselection.DefaultTrackSelector
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
...
@@ -219,6 +221,27 @@ public interface ExoPlayer extends Player {
...
@@ -219,6 +221,27 @@ public interface ExoPlayer extends Player {
boolean
getSkipSilenceEnabled
();
boolean
getSkipSilenceEnabled
();
}
}
/** The text component of an {@link ExoPlayer}. */
interface
TextComponent
{
/**
* Registers an output to receive text events.
*
* @param listener The output to register.
*/
void
addTextOutput
(
TextOutput
listener
);
/**
* Removes a text output.
*
* @param listener The output to remove.
*/
void
removeTextOutput
(
TextOutput
listener
);
/** Returns the current {@link Cue Cues}. This list may be empty. */
List
<
Cue
>
getCurrentCues
();
}
/** The metadata component of an {@link ExoPlayer}. */
/** The metadata component of an {@link ExoPlayer}. */
interface
MetadataComponent
{
interface
MetadataComponent
{
...
@@ -580,6 +603,10 @@ public interface ExoPlayer extends Player {
...
@@ -580,6 +603,10 @@ public interface ExoPlayer extends Player {
@Nullable
@Nullable
AudioComponent
getAudioComponent
();
AudioComponent
getAudioComponent
();
/** Returns the component of this player for text output, or null if text is not supported. */
@Nullable
TextComponent
getTextComponent
();
/**
/**
* Returns the component of this player for metadata output, or null if metadata is not supported.
* Returns the component of this player for metadata output, or null if metadata is not supported.
*/
*/
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
5ae84ab5
...
@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
...
@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import
com.google.android.exoplayer2.source.MediaSourceFactory
;
import
com.google.android.exoplayer2.source.MediaSourceFactory
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.source.ShuffleOrder
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.trackselection.ExoTrackSelection
;
import
com.google.android.exoplayer2.trackselection.ExoTrackSelection
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
...
@@ -1002,6 +1003,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
...
@@ -1002,6 +1003,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
return
1
;
return
1
;
}
}
/** This method is not supported and returns an empty list. */
@Override
public
ImmutableList
<
Cue
>
getCurrentCues
()
{
return
ImmutableList
.
of
();
}
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 @
5ae84ab5
...
@@ -80,7 +80,7 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -80,7 +80,7 @@ public class SimpleExoPlayer extends BasePlayer
implements
ExoPlayer
,
implements
ExoPlayer
,
ExoPlayer
.
AudioComponent
,
ExoPlayer
.
AudioComponent
,
Player
.
VideoComponent
,
Player
.
VideoComponent
,
Player
.
TextComponent
,
Exo
Player
.
TextComponent
,
ExoPlayer
.
MetadataComponent
,
ExoPlayer
.
MetadataComponent
,
Player
.
DeviceComponent
{
Player
.
DeviceComponent
{
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
View file @
5ae84ab5
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_TEXT
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
...
@@ -56,7 +58,6 @@ import com.google.android.exoplayer2.metadata.flac.PictureFrame;
...
@@ -56,7 +58,6 @@ import com.google.android.exoplayer2.metadata.flac.PictureFrame;
import
com.google.android.exoplayer2.metadata.id3.ApicFrame
;
import
com.google.android.exoplayer2.metadata.id3.ApicFrame
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.TextOutput
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionUtil
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionUtil
;
import
com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode
;
import
com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode
;
...
@@ -562,7 +563,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
...
@@ -562,7 +563,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
oldPlayer
.
removeListener
(
componentListener
);
oldPlayer
.
removeListener
(
componentListener
);
@Nullable
Player
.
VideoComponent
oldVideoComponent
=
oldPlayer
.
getVideoComponent
();
@Nullable
Player
.
VideoComponent
oldVideoComponent
=
oldPlayer
.
getVideoComponent
();
if
(
oldVideoComponent
!=
null
)
{
if
(
oldVideoComponent
!=
null
)
{
oldVideoComponent
.
removeVideoListener
(
componentListener
);
if
(
surfaceView
instanceof
TextureView
)
{
if
(
surfaceView
instanceof
TextureView
)
{
oldVideoComponent
.
clearVideoTextureView
((
TextureView
)
surfaceView
);
oldVideoComponent
.
clearVideoTextureView
((
TextureView
)
surfaceView
);
}
else
if
(
surfaceView
instanceof
SphericalGLSurfaceView
)
{
}
else
if
(
surfaceView
instanceof
SphericalGLSurfaceView
)
{
...
@@ -571,10 +571,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
...
@@ -571,10 +571,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
oldVideoComponent
.
clearVideoSurfaceView
((
SurfaceView
)
surfaceView
);
oldVideoComponent
.
clearVideoSurfaceView
((
SurfaceView
)
surfaceView
);
}
}
}
}
@Nullable
Player
.
TextComponent
oldTextComponent
=
oldPlayer
.
getTextComponent
();
if
(
oldTextComponent
!=
null
)
{
oldTextComponent
.
removeTextOutput
(
componentListener
);
}
}
}
if
(
subtitleView
!=
null
)
{
if
(
subtitleView
!=
null
)
{
subtitleView
.
setCues
(
null
);
subtitleView
.
setCues
(
null
);
...
@@ -598,12 +594,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
...
@@ -598,12 +594,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
}
}
newVideoComponent
.
addVideoListener
(
componentListener
);
newVideoComponent
.
addVideoListener
(
componentListener
);
}
}
@Nullable
Player
.
TextComponent
newTextComponent
=
player
.
getTextComponent
();
if
(
subtitleView
!=
null
&&
player
.
isCommandAvailable
(
COMMAND_GET_TEXT
))
{
if
(
newTextComponent
!=
null
)
{
subtitleView
.
setCues
(
player
.
getCurrentCues
());
newTextComponent
.
addTextOutput
(
componentListener
);
if
(
subtitleView
!=
null
)
{
subtitleView
.
setCues
(
newTextComponent
.
getCurrentCues
());
}
}
}
player
.
addListener
(
componentListener
);
player
.
addListener
(
componentListener
);
maybeShowController
(
false
);
maybeShowController
(
false
);
...
@@ -1491,8 +1483,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
...
@@ -1491,8 +1483,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
}
}
private
final
class
ComponentListener
private
final
class
ComponentListener
implements
Player
.
EventListener
,
implements
Player
.
Listener
,
TextOutput
,
VideoListener
,
VideoListener
,
OnLayoutChangeListener
,
OnLayoutChangeListener
,
SingleTapListener
,
SingleTapListener
,
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
View file @
5ae84ab5
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_TEXT
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
...
@@ -571,7 +572,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
...
@@ -571,7 +572,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
oldPlayer
.
removeListener
(
componentListener
);
oldPlayer
.
removeListener
(
componentListener
);
@Nullable
Player
.
VideoComponent
oldVideoComponent
=
oldPlayer
.
getVideoComponent
();
@Nullable
Player
.
VideoComponent
oldVideoComponent
=
oldPlayer
.
getVideoComponent
();
if
(
oldVideoComponent
!=
null
)
{
if
(
oldVideoComponent
!=
null
)
{
oldVideoComponent
.
removeVideoListener
(
componentListener
);
if
(
surfaceView
instanceof
TextureView
)
{
if
(
surfaceView
instanceof
TextureView
)
{
oldVideoComponent
.
clearVideoTextureView
((
TextureView
)
surfaceView
);
oldVideoComponent
.
clearVideoTextureView
((
TextureView
)
surfaceView
);
}
else
if
(
surfaceView
instanceof
SphericalGLSurfaceView
)
{
}
else
if
(
surfaceView
instanceof
SphericalGLSurfaceView
)
{
...
@@ -580,10 +580,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
...
@@ -580,10 +580,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
oldVideoComponent
.
clearVideoSurfaceView
((
SurfaceView
)
surfaceView
);
oldVideoComponent
.
clearVideoSurfaceView
((
SurfaceView
)
surfaceView
);
}
}
}
}
@Nullable
Player
.
TextComponent
oldTextComponent
=
oldPlayer
.
getTextComponent
();
if
(
oldTextComponent
!=
null
)
{
oldTextComponent
.
removeTextOutput
(
componentListener
);
}
}
}
if
(
subtitleView
!=
null
)
{
if
(
subtitleView
!=
null
)
{
subtitleView
.
setCues
(
null
);
subtitleView
.
setCues
(
null
);
...
@@ -607,12 +603,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
...
@@ -607,12 +603,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
}
}
newVideoComponent
.
addVideoListener
(
componentListener
);
newVideoComponent
.
addVideoListener
(
componentListener
);
}
}
@Nullable
Player
.
TextComponent
newTextComponent
=
player
.
getTextComponent
();
if
(
subtitleView
!=
null
&&
player
.
isCommandAvailable
(
COMMAND_GET_TEXT
))
{
if
(
newTextComponent
!=
null
)
{
subtitleView
.
setCues
(
player
.
getCurrentCues
());
newTextComponent
.
addTextOutput
(
componentListener
);
if
(
subtitleView
!=
null
)
{
subtitleView
.
setCues
(
newTextComponent
.
getCurrentCues
());
}
}
}
player
.
addListener
(
componentListener
);
player
.
addListener
(
componentListener
);
maybeShowController
(
false
);
maybeShowController
(
false
);
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
5ae84ab5
...
@@ -32,6 +32,7 @@ import com.google.android.exoplayer2.metadata.Metadata;
...
@@ -32,6 +32,7 @@ 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
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.source.TrackGroupArray
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelectionArray
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
import
com.google.android.exoplayer2.trackselection.TrackSelector
;
import
com.google.android.exoplayer2.util.Clock
;
import
com.google.android.exoplayer2.util.Clock
;
...
@@ -439,6 +440,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
...
@@ -439,6 +440,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
}
@Override
@Override
public
List
<
Cue
>
getCurrentCues
()
{
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