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
6c31e345
authored
Nov 23, 2020
by
olly
Committed by
kim-vde
Nov 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Use onEvents in PlayerControlView/StyledPlayerControlView
#exofixit PiperOrigin-RevId: 343821736
parent
e5e903eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
88 deletions
library/core/src/main/java/com/google/android/exoplayer2/Player.java
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java
library/core/src/main/java/com/google/android/exoplayer2/util/MutableFlags.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java
library/core/src/main/java/com/google/android/exoplayer2/Player.java
View file @
6c31e345
...
@@ -757,6 +757,18 @@ public interface Player {
...
@@ -757,6 +757,18 @@ public interface Player {
}
}
/**
/**
* Returns whether any of the given events occurred.
*
* @param events The {@link EventFlags events}.
* @return Whether any of the events occurred.
*/
@Override
public
boolean
containsAny
(
@EventFlags
int
...
events
)
{
// Overridden to add IntDef compiler enforcement and new JavaDoc.
return
super
.
containsAny
(
events
);
}
/**
* Returns the {@link EventFlags event} at the given index.
* Returns the {@link EventFlags event} at the given index.
*
*
* <p>Although index-based access is possible, it doesn't imply a particular order of these
* <p>Although index-based access is possible, it doesn't imply a particular order of these
...
...
library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java
View file @
6c31e345
...
@@ -111,6 +111,18 @@ public interface AnalyticsListener {
...
@@ -111,6 +111,18 @@ public interface AnalyticsListener {
}
}
/**
/**
* Returns whether any of the given events occurred.
*
* @param events The {@link EventFlags events}.
* @return Whether any of the events occurred.
*/
@Override
public
boolean
containsAny
(
@EventFlags
int
...
events
)
{
// Overridden to add IntDef compiler enforcement and new JavaDoc.
return
super
.
containsAny
(
events
);
}
/**
* Returns the {@link EventFlags event} at the given index.
* Returns the {@link EventFlags event} at the given index.
*
*
* <p>Although index-based access is possible, it doesn't imply a particular order of these
* <p>Although index-based access is possible, it doesn't imply a particular order of these
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/MutableFlags.java
View file @
6c31e345
...
@@ -57,6 +57,21 @@ public class MutableFlags {
...
@@ -57,6 +57,21 @@ public class MutableFlags {
return
flags
.
get
(
flag
);
return
flags
.
get
(
flag
);
}
}
/**
* Returns whether the set contains at least one of the given flags.
*
* @param flags The flags.
* @return Whether the set contains at least one of the flags.
*/
public
boolean
containsAny
(
int
...
flags
)
{
for
(
int
flag
:
flags
)
{
if
(
contains
(
flag
))
{
return
true
;
}
}
return
false
;
}
/** Returns the number of flags in this set. */
/** Returns the number of flags in this set. */
public
int
size
()
{
public
int
size
()
{
return
flags
.
size
();
return
flags
.
size
();
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
View file @
6c31e345
...
@@ -15,6 +15,14 @@
...
@@ -15,6 +15,14 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_IS_PLAYING_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_PLAYBACK_STATE_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_PLAY_WHEN_READY_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_POSITION_DISCONTINUITY
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_REPEAT_MODE_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_TIMELINE_CHANGED
;
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
;
...
@@ -38,6 +46,7 @@ import com.google.android.exoplayer2.DefaultControlDispatcher;
...
@@ -38,6 +46,7 @@ import com.google.android.exoplayer2.DefaultControlDispatcher;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.PlaybackPreparer
;
import
com.google.android.exoplayer2.PlaybackPreparer
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player.Events
;
import
com.google.android.exoplayer2.Player.State
;
import
com.google.android.exoplayer2.Player.State
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
...
@@ -1336,45 +1345,30 @@ public class PlayerControlView extends FrameLayout {
...
@@ -1336,45 +1345,30 @@ public class PlayerControlView extends FrameLayout {
}
}
@Override
@Override
public
void
onPlaybackStateChanged
(
@Player
.
State
int
playbackState
)
{
public
void
onEvents
(
Player
player
,
Events
events
)
{
updatePlayPauseButton
();
if
(
events
.
containsAny
(
EVENT_PLAYBACK_STATE_CHANGED
,
EVENT_PLAY_WHEN_READY_CHANGED
))
{
updateProgress
();
updatePlayPauseButton
();
}
}
if
(
events
.
containsAny
(
@Override
EVENT_PLAYBACK_STATE_CHANGED
,
EVENT_PLAY_WHEN_READY_CHANGED
,
EVENT_IS_PLAYING_CHANGED
))
{
public
void
onPlayWhenReadyChanged
(
updateProgress
();
boolean
playWhenReady
,
@Player
.
PlayWhenReadyChangeReason
int
reason
)
{
}
updatePlayPauseButton
();
if
(
events
.
contains
(
EVENT_REPEAT_MODE_CHANGED
))
{
updateProgress
();
updateRepeatModeButton
();
}
}
if
(
events
.
contains
(
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
))
{
@Override
updateShuffleButton
();
public
void
onIsPlayingChanged
(
boolean
isPlaying
)
{
}
updateProgress
();
if
(
events
.
containsAny
(
}
EVENT_REPEAT_MODE_CHANGED
,
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
,
@Override
EVENT_POSITION_DISCONTINUITY
,
public
void
onRepeatModeChanged
(
int
repeatMode
)
{
EVENT_TIMELINE_CHANGED
))
{
updateRepeatModeButton
();
updateNavigation
();
updateNavigation
();
}
}
if
(
events
.
containsAny
(
EVENT_POSITION_DISCONTINUITY
,
EVENT_TIMELINE_CHANGED
))
{
updateTimeline
();
@Override
}
public
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{
updateShuffleButton
();
updateNavigation
();
}
@Override
public
void
onPositionDiscontinuity
(
@Player
.
DiscontinuityReason
int
reason
)
{
updateNavigation
();
updateTimeline
();
}
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
@Player
.
TimelineChangeReason
int
reason
)
{
updateNavigation
();
updateTimeline
();
}
}
@Override
@Override
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java
View file @
6c31e345
...
@@ -15,6 +15,15 @@
...
@@ -15,6 +15,15 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_IS_PLAYING_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_PLAYBACK_PARAMETERS_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_PLAYBACK_STATE_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_PLAY_WHEN_READY_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_POSITION_DISCONTINUITY
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_REPEAT_MODE_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_TIMELINE_CHANGED
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
EVENT_TRACKS_CHANGED
;
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
;
...
@@ -45,6 +54,7 @@ import com.google.android.exoplayer2.Format;
...
@@ -45,6 +54,7 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.PlaybackParameters
;
import
com.google.android.exoplayer2.PlaybackParameters
;
import
com.google.android.exoplayer2.PlaybackPreparer
;
import
com.google.android.exoplayer2.PlaybackPreparer
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player.Events
;
import
com.google.android.exoplayer2.Player.State
;
import
com.google.android.exoplayer2.Player.State
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
...
@@ -1767,55 +1777,36 @@ public class StyledPlayerControlView extends FrameLayout {
...
@@ -1767,55 +1777,36 @@ public class StyledPlayerControlView extends FrameLayout {
}
}
@Override
@Override
public
void
onPlaybackStateChanged
(
@Player
.
State
int
playbackState
)
{
public
void
onEvents
(
Player
player
,
Events
events
)
{
updatePlayPauseButton
();
if
(
events
.
containsAny
(
EVENT_PLAYBACK_STATE_CHANGED
,
EVENT_PLAY_WHEN_READY_CHANGED
))
{
updateProgress
();
updatePlayPauseButton
();
}
}
if
(
events
.
containsAny
(
@Override
EVENT_PLAYBACK_STATE_CHANGED
,
EVENT_PLAY_WHEN_READY_CHANGED
,
EVENT_IS_PLAYING_CHANGED
))
{
public
void
onPlayWhenReadyChanged
(
updateProgress
();
boolean
playWhenReady
,
@Player
.
PlayWhenReadyChangeReason
int
state
)
{
}
updatePlayPauseButton
();
if
(
events
.
contains
(
EVENT_REPEAT_MODE_CHANGED
))
{
updateProgress
();
updateRepeatModeButton
();
}
}
if
(
events
.
contains
(
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
))
{
@Override
updateShuffleButton
();
public
void
onIsPlayingChanged
(
boolean
isPlaying
)
{
}
updateProgress
();
if
(
events
.
containsAny
(
}
EVENT_REPEAT_MODE_CHANGED
,
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
,
@Override
EVENT_POSITION_DISCONTINUITY
,
public
void
onRepeatModeChanged
(
int
repeatMode
)
{
EVENT_TIMELINE_CHANGED
))
{
updateRepeatModeButton
();
updateNavigation
();
updateNavigation
();
}
}
if
(
events
.
containsAny
(
EVENT_POSITION_DISCONTINUITY
,
EVENT_TIMELINE_CHANGED
))
{
updateTimeline
();
@Override
}
public
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{
if
(
events
.
contains
(
EVENT_PLAYBACK_PARAMETERS_CHANGED
))
{
updateShuffleButton
();
updateSettingsPlaybackSpeedLists
();
updateNavigation
();
}
}
if
(
events
.
contains
(
EVENT_TRACKS_CHANGED
))
{
updateTrackLists
();
@Override
}
public
void
onPositionDiscontinuity
(
@Player
.
DiscontinuityReason
int
reason
)
{
updateNavigation
();
updateTimeline
();
}
@Override
public
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{
updateSettingsPlaybackSpeedLists
();
}
@Override
public
void
onTracksChanged
(
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{
updateTrackLists
();
}
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
@Player
.
TimelineChangeReason
int
reason
)
{
updateNavigation
();
updateTimeline
();
}
}
@Override
@Override
...
...
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