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
62e6455d
authored
Feb 12, 2019
by
Arnold Szabo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Taking consideration the current position before calculating the delay before the next update
parent
c905891d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
View file @
62e6455d
...
...
@@ -24,6 +24,7 @@ import android.os.Looper;
import
android.os.SystemClock
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
...
...
@@ -838,20 +839,32 @@ public class PlayerControlView extends FrameLayout {
if
(
playbackSpeed
<=
0.1f
)
{
delayMs
=
1000
;
}
else
if
(
playbackSpeed
<=
5
f
)
{
/*long mediaTimeUpdatePeriodMs = 1000 / Math.max(1, Math.round(1 / playbackSpeed));
long mediaTimeDelayMs = mediaTimeUpdatePeriodMs - (position % mediaTimeUpdatePeriodMs);
if (mediaTimeDelayMs < (mediaTimeUpdatePeriodMs / 5)) {
mediaTimeDelayMs += mediaTimeUpdatePeriodMs;
}*/
int
timeBarWidth
=
timeBar
.
getTimeBarWidth
();
// Calculate how many updates needs to be done with DEFAULT_UPDATE_DP
// to fill up the time bar
int
numberOfUpdates
=
timeBarWidth
/
DEFAULT_UPDATE_DP
;
long
mediaTimeDelayMs
=
duration
/
numberOfUpdates
;
if
(
mediaTimeDelayMs
<
MIN_UPDATE_FREQUENCY_MS
)
{
mediaTimeDelayMs
=
MIN_UPDATE_FREQUENCY_MS
;
}
else
if
(
mediaTimeDelayMs
>=
MAX_UPDATE_FREQUENCY_MS
)
{
mediaTimeDelayMs
=
MAX_UPDATE_FREQUENCY_MS
;
// Calculate the designated update interval, taking duration into consideration as well
long
mediaTimeUpdatePeriodMs
=
duration
/
numberOfUpdates
;
// Limit the designated update interval, to avoid too frequent / infrequent updates
if
(
mediaTimeUpdatePeriodMs
<
MIN_UPDATE_FREQUENCY_MS
)
{
mediaTimeUpdatePeriodMs
=
MIN_UPDATE_FREQUENCY_MS
;
}
else
if
(
mediaTimeUpdatePeriodMs
>=
MAX_UPDATE_FREQUENCY_MS
)
{
mediaTimeUpdatePeriodMs
=
MAX_UPDATE_FREQUENCY_MS
;
}
// Calculate the delay needed from the current position until the next update is due
long
mediaTimeDelayMs
=
mediaTimeUpdatePeriodMs
-
(
position
%
mediaTimeUpdatePeriodMs
);
// If the delay would be too small, then skip the next update
if
(
mediaTimeDelayMs
<
(
mediaTimeUpdatePeriodMs
/
5
))
{
mediaTimeDelayMs
+=
mediaTimeUpdatePeriodMs
;
}
// Calculate the delay until the next update (in real time), taking
// playbackSpeed into consideration
delayMs
=
playbackSpeed
==
1
?
mediaTimeDelayMs
:
(
long
)
(
mediaTimeDelayMs
/
playbackSpeed
);
}
else
{
delayMs
=
200
;
...
...
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