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
ecfce462
authored
Feb 13, 2019
by
Arnold Szabo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Changes according to the code review
parent
62e6455d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
22 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java
View file @
ecfce462
...
@@ -205,6 +205,7 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -205,6 +205,7 @@ public class DefaultTimeBar extends View implements TimeBar {
private
final
CopyOnWriteArraySet
<
OnScrubListener
>
listeners
;
private
final
CopyOnWriteArraySet
<
OnScrubListener
>
listeners
;
private
final
int
[]
locationOnScreen
;
private
final
int
[]
locationOnScreen
;
private
final
Point
touchPosition
;
private
final
Point
touchPosition
;
private
final
float
density
;
private
int
keyCountIncrement
;
private
int
keyCountIncrement
;
private
long
keyTimeIncrement
;
private
long
keyTimeIncrement
;
...
@@ -219,8 +220,6 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -219,8 +220,6 @@ public class DefaultTimeBar extends View implements TimeBar {
private
@Nullable
long
[]
adGroupTimesMs
;
private
@Nullable
long
[]
adGroupTimesMs
;
private
@Nullable
boolean
[]
playedAdGroups
;
private
@Nullable
boolean
[]
playedAdGroups
;
private
int
densityDpi
;
/** Creates a new time bar. */
/** Creates a new time bar. */
// Suppress warnings due to usage of View methods in the constructor.
// Suppress warnings due to usage of View methods in the constructor.
@SuppressWarnings
(
"nullness:method.invocation.invalid"
)
@SuppressWarnings
(
"nullness:method.invocation.invalid"
)
...
@@ -244,7 +243,7 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -244,7 +243,7 @@ public class DefaultTimeBar extends View implements TimeBar {
// Calculate the dimensions and paints for drawn elements.
// Calculate the dimensions and paints for drawn elements.
Resources
res
=
context
.
getResources
();
Resources
res
=
context
.
getResources
();
DisplayMetrics
displayMetrics
=
res
.
getDisplayMetrics
();
DisplayMetrics
displayMetrics
=
res
.
getDisplayMetrics
();
density
Dpi
=
displayMetrics
.
densityDpi
;
density
=
displayMetrics
.
density
;
fineScrubYThreshold
=
dpToPx
(
displayMetrics
,
FINE_SCRUB_Y_THRESHOLD_DP
);
fineScrubYThreshold
=
dpToPx
(
displayMetrics
,
FINE_SCRUB_Y_THRESHOLD_DP
);
int
defaultBarHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_BAR_HEIGHT_DP
);
int
defaultBarHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_BAR_HEIGHT_DP
);
int
defaultTouchTargetHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_TOUCH_TARGET_HEIGHT_DP
);
int
defaultTouchTargetHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_TOUCH_TARGET_HEIGHT_DP
);
...
@@ -451,8 +450,8 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -451,8 +450,8 @@ public class DefaultTimeBar extends View implements TimeBar {
}
}
@Override
@Override
public
int
getTimeBarWidth
()
{
public
int
getTimeBarWidth
Dp
()
{
return
pxToDp
(
density
Dpi
,
getWidth
());
return
pxToDp
(
density
,
getWidth
());
}
}
// View methods.
// View methods.
...
@@ -844,7 +843,7 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -844,7 +843,7 @@ public class DefaultTimeBar extends View implements TimeBar {
return
(
int
)
(
dps
*
displayMetrics
.
density
+
0.5f
);
return
(
int
)
(
dps
*
displayMetrics
.
density
+
0.5f
);
}
}
private
static
int
pxToDp
(
int
densityDpi
,
int
px
)
{
private
static
int
pxToDp
(
float
density
,
int
px
)
{
return
(
int
)
(
px
/
((
float
)
densityDpi
/
DisplayMetrics
.
DENSITY_DEFAULT
)
);
return
(
int
)
(
px
/
density
);
}
}
}
}
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
View file @
ecfce462
...
@@ -836,11 +836,11 @@ public class PlayerControlView extends FrameLayout {
...
@@ -836,11 +836,11 @@ public class PlayerControlView extends FrameLayout {
long
delayMs
;
long
delayMs
;
if
(
player
.
getPlayWhenReady
()
&&
playbackState
==
Player
.
STATE_READY
)
{
if
(
player
.
getPlayWhenReady
()
&&
playbackState
==
Player
.
STATE_READY
)
{
float
playbackSpeed
=
player
.
getPlaybackParameters
().
speed
;
float
playbackSpeed
=
player
.
getPlaybackParameters
().
speed
;
if
(
playbackSpeed
<=
0.1f
)
{
int
timeBarWidth
=
timeBar
.
getTimeBarWidthDp
();
delayMs
=
1000
;
}
else
if
(
playbackSpeed
<=
5
f
)
{
int
timeBarWidth
=
timeBar
.
getTimeBarWidth
();
if
(
timeBarWidth
==
0
||
duration
==
0
)
{
delayMs
=
MAX_UPDATE_FREQUENCY_MS
;
}
else
{
// Calculate how many updates needs to be done with DEFAULT_UPDATE_DP
// Calculate how many updates needs to be done with DEFAULT_UPDATE_DP
// to fill up the time bar
// to fill up the time bar
int
numberOfUpdates
=
timeBarWidth
/
DEFAULT_UPDATE_DP
;
int
numberOfUpdates
=
timeBarWidth
/
DEFAULT_UPDATE_DP
;
...
@@ -848,13 +848,6 @@ public class PlayerControlView extends FrameLayout {
...
@@ -848,13 +848,6 @@ public class PlayerControlView extends FrameLayout {
// Calculate the designated update interval, taking duration into consideration as well
// Calculate the designated update interval, taking duration into consideration as well
long
mediaTimeUpdatePeriodMs
=
duration
/
numberOfUpdates
;
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
// Calculate the delay needed from the current position until the next update is due
long
mediaTimeDelayMs
=
mediaTimeUpdatePeriodMs
-
(
position
%
mediaTimeUpdatePeriodMs
);
long
mediaTimeDelayMs
=
mediaTimeUpdatePeriodMs
-
(
position
%
mediaTimeUpdatePeriodMs
);
...
@@ -866,11 +859,16 @@ public class PlayerControlView extends FrameLayout {
...
@@ -866,11 +859,16 @@ public class PlayerControlView extends FrameLayout {
// Calculate the delay until the next update (in real time), taking
// Calculate the delay until the next update (in real time), taking
// playbackSpeed into consideration
// playbackSpeed into consideration
delayMs
=
playbackSpeed
==
1
?
mediaTimeDelayMs
:
(
long
)
(
mediaTimeDelayMs
/
playbackSpeed
);
delayMs
=
playbackSpeed
==
1
?
mediaTimeDelayMs
:
(
long
)
(
mediaTimeDelayMs
/
playbackSpeed
);
}
else
{
delayMs
=
200
;
// Limit the delay if needed, to avoid too frequent / infrequent updates
if
(
delayMs
<
MIN_UPDATE_FREQUENCY_MS
)
{
delayMs
=
MIN_UPDATE_FREQUENCY_MS
;
}
else
if
(
delayMs
>=
MAX_UPDATE_FREQUENCY_MS
)
{
delayMs
=
MAX_UPDATE_FREQUENCY_MS
;
}
}
}
}
else
{
}
else
{
delayMs
=
1000
;
delayMs
=
MAX_UPDATE_FREQUENCY_MS
;
}
}
postDelayed
(
updateProgressAction
,
delayMs
);
postDelayed
(
updateProgressAction
,
delayMs
);
}
}
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java
View file @
ecfce462
...
@@ -102,7 +102,7 @@ public interface TimeBar {
...
@@ -102,7 +102,7 @@ public interface TimeBar {
*
*
* @return Width of time bar in dps
* @return Width of time bar in dps
*/
*/
int
getTimeBarWidth
();
int
getTimeBarWidth
Dp
();
/**
/**
* Listener for scrubbing events.
* Listener for scrubbing events.
...
...
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