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
56e97783
authored
Jun 16, 2021
by
kimvde
Committed by
Oliver Woodman
Jun 21, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Simplify DefaultControlDispatcher by using Player methods
PiperOrigin-RevId: 379732136
parent
63f12f02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
17 deletions
library/common/src/main/java/com/google/android/exoplayer2/DefaultControlDispatcher.java
library/common/src/main/java/com/google/android/exoplayer2/DefaultControlDispatcher.java
View file @
56e97783
...
...
@@ -28,7 +28,6 @@ public class DefaultControlDispatcher implements ControlDispatcher {
private
static
final
int
MAX_POSITION_FOR_SEEK_TO_PREVIOUS
=
3000
;
private
final
Timeline
.
Window
window
;
private
final
long
rewindIncrementMs
;
private
final
long
fastForwardIncrementMs
;
...
...
@@ -48,7 +47,6 @@ public class DefaultControlDispatcher implements ControlDispatcher {
public
DefaultControlDispatcher
(
long
fastForwardIncrementMs
,
long
rewindIncrementMs
)
{
this
.
fastForwardIncrementMs
=
fastForwardIncrementMs
;
this
.
rewindIncrementMs
=
rewindIncrementMs
;
window
=
new
Timeline
.
Window
();
}
@Override
...
...
@@ -75,16 +73,14 @@ public class DefaultControlDispatcher implements ControlDispatcher {
if
(
timeline
.
isEmpty
()
||
player
.
isPlayingAd
())
{
return
true
;
}
int
windowIndex
=
player
.
getCurrentWindowIndex
();
timeline
.
getWindow
(
windowIndex
,
window
);
int
previousWindowIndex
=
player
.
getPreviousWindowIndex
();
boolean
isUnseekableLiveStream
=
window
.
isLive
()
&&
!
window
.
isSeekable
;
if
(
previousWindowIndex
!=
C
.
INDEX_UNSET
boolean
isUnseekableLiveStream
=
player
.
isCurrentWindowLive
()
&&
!
player
.
isCurrentWindowSeekable
();
if
(
player
.
hasPrevious
()
&&
(
player
.
getCurrentPosition
()
<=
MAX_POSITION_FOR_SEEK_TO_PREVIOUS
||
isUnseekableLiveStream
))
{
player
.
seekTo
(
previousWindowIndex
,
C
.
TIME_UNSET
);
player
.
previous
(
);
}
else
if
(!
isUnseekableLiveStream
)
{
player
.
seekTo
(
windowIndex
,
/* positionMs= */
0
);
player
.
seekTo
(
/* positionMs= */
0
);
}
return
true
;
}
...
...
@@ -95,13 +91,10 @@ public class DefaultControlDispatcher implements ControlDispatcher {
if
(
timeline
.
isEmpty
()
||
player
.
isPlayingAd
())
{
return
true
;
}
int
windowIndex
=
player
.
getCurrentWindowIndex
();
timeline
.
getWindow
(
windowIndex
,
window
);
int
nextWindowIndex
=
player
.
getNextWindowIndex
();
if
(
nextWindowIndex
!=
C
.
INDEX_UNSET
)
{
player
.
seekTo
(
nextWindowIndex
,
C
.
TIME_UNSET
);
}
else
if
(
window
.
isLive
()
&&
window
.
isDynamic
)
{
player
.
seekTo
(
windowIndex
,
C
.
TIME_UNSET
);
if
(
player
.
hasNext
())
{
player
.
next
();
}
else
if
(
player
.
isCurrentWindowLive
()
&&
player
.
isCurrentWindowDynamic
())
{
player
.
seekToDefaultPosition
();
}
return
true
;
}
...
...
@@ -176,6 +169,6 @@ public class DefaultControlDispatcher implements ControlDispatcher {
positionMs
=
min
(
positionMs
,
durationMs
);
}
positionMs
=
max
(
positionMs
,
0
);
player
.
seekTo
(
p
layer
.
getCurrentWindowIndex
(),
p
ositionMs
);
player
.
seekTo
(
positionMs
);
}
}
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