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
f82bc244
authored
Mar 11, 2020
by
olly
Committed by
Oliver Woodman
Mar 11, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add show/hideScrubber to DefaultTimeBar
PiperOrigin-RevId: 300249371
parent
c6e8e24a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
14 deletions
RELEASENOTES.md
library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java
RELEASENOTES.md
View file @
f82bc244
...
@@ -87,6 +87,7 @@
...
@@ -87,6 +87,7 @@
*
Upgrade Truth dependency from 0.44 to 1.0.
*
Upgrade Truth dependency from 0.44 to 1.0.
*
Upgrade to JUnit 4.13-rc-2.
*
Upgrade to JUnit 4.13-rc-2.
*
UI
*
UI
*
Add
`showScrubber`
and
`hideScrubber`
methods to DefaultTimeBar.
*
Move logic of prev, next, fast forward and rewind to ControlDispatcher
*
Move logic of prev, next, fast forward and rewind to ControlDispatcher
(
[
#6926
](
https://github.com/google/ExoPlayer/issues/6926
)
).
(
[
#6926
](
https://github.com/google/ExoPlayer/issues/6926
)
).
*
Demo apps: Add
*
Demo apps: Add
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java
View file @
f82bc244
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
android.animation.ValueAnimator
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
...
@@ -163,6 +164,9 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -163,6 +164,9 @@ public class DefaultTimeBar extends View implements TimeBar {
private
static
final
int
DEFAULT_INCREMENT_COUNT
=
20
;
private
static
final
int
DEFAULT_INCREMENT_COUNT
=
20
;
private
static
final
float
SHOWN_SCRUBBER_SCALE
=
1.0f
;
private
static
final
float
HIDDEN_SCRUBBER_SCALE
=
0.0f
;
/**
/**
* The name of the Android SDK view that most closely resembles this custom view. Used as the
* The name of the Android SDK view that most closely resembles this custom view. Used as the
* class name for accessibility.
* class name for accessibility.
...
@@ -201,6 +205,7 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -201,6 +205,7 @@ public class DefaultTimeBar extends View implements TimeBar {
private
int
lastCoarseScrubXPosition
;
private
int
lastCoarseScrubXPosition
;
private
@MonotonicNonNull
Rect
lastExclusionRectangle
;
private
@MonotonicNonNull
Rect
lastExclusionRectangle
;
private
ValueAnimator
scrubberScalingAnimator
;
private
float
scrubberScale
;
private
float
scrubberScale
;
private
boolean
scrubbing
;
private
boolean
scrubbing
;
private
long
scrubPosition
;
private
long
scrubPosition
;
...
@@ -326,6 +331,12 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -326,6 +331,12 @@ public class DefaultTimeBar extends View implements TimeBar {
/
2
;
/
2
;
}
}
scrubberScale
=
1.0f
;
scrubberScale
=
1.0f
;
scrubberScalingAnimator
=
new
ValueAnimator
();
scrubberScalingAnimator
.
addUpdateListener
(
animation
->
{
scrubberScale
=
(
float
)
animation
.
getAnimatedValue
();
invalidate
(
seekBounds
);
});
duration
=
C
.
TIME_UNSET
;
duration
=
C
.
TIME_UNSET
;
keyTimeIncrement
=
C
.
TIME_UNSET
;
keyTimeIncrement
=
C
.
TIME_UNSET
;
keyCountIncrement
=
DEFAULT_INCREMENT_COUNT
;
keyCountIncrement
=
DEFAULT_INCREMENT_COUNT
;
...
@@ -335,6 +346,44 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -335,6 +346,44 @@ public class DefaultTimeBar extends View implements TimeBar {
}
}
}
}
/** Shows the scrubber handle. */
public
void
showScrubber
()
{
showScrubber
(
/* showAnimationDurationMs= */
0
);
}
/**
* Shows the scrubber handle with animation.
*
* @param showAnimationDurationMs The duration for scrubber showing animation.
*/
public
void
showScrubber
(
long
showAnimationDurationMs
)
{
if
(
scrubberScalingAnimator
.
isStarted
())
{
scrubberScalingAnimator
.
cancel
();
}
scrubberScalingAnimator
.
setFloatValues
(
scrubberScale
,
SHOWN_SCRUBBER_SCALE
);
scrubberScalingAnimator
.
setDuration
(
showAnimationDurationMs
);
scrubberScalingAnimator
.
start
();
}
/** Hides the scrubber handle. */
public
void
hideScrubber
()
{
hideScrubber
(
/* hideAnimationDurationMs= */
0
);
}
/**
* Hides the scrubber handle with animation.
*
* @param hideAnimationDurationMs The duration for scrubber hiding animation.
*/
public
void
hideScrubber
(
long
hideAnimationDurationMs
)
{
if
(
scrubberScalingAnimator
.
isStarted
())
{
scrubberScalingAnimator
.
cancel
();
}
scrubberScalingAnimator
.
setFloatValues
(
scrubberScale
,
HIDDEN_SCRUBBER_SCALE
);
scrubberScalingAnimator
.
setDuration
(
hideAnimationDurationMs
);
scrubberScalingAnimator
.
start
();
}
/**
/**
* Sets the color for the portion of the time bar representing media before the playback position.
* Sets the color for the portion of the time bar representing media before the playback position.
*
*
...
@@ -357,18 +406,6 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -357,18 +406,6 @@ public class DefaultTimeBar extends View implements TimeBar {
}
}
/**
/**
* Sets the scale factor for the scrubber handle. Scrubber enabled size, scrubber disabled size,
* scrubber dragged size are scaled by the scale factor. If scrubber drawable is set, the scale
* factor isn't applied.
*
* @param scrubberScale The scale factor for the scrubber handle.
*/
public
void
setScrubberScale
(
float
scrubberScale
)
{
this
.
scrubberScale
=
scrubberScale
;
invalidate
(
seekBounds
);
}
/**
* Sets the color for the portion of the time bar after the current played position up to the
* Sets the color for the portion of the time bar after the current played position up to the
* current buffered position.
* current buffered position.
*
*
...
@@ -829,8 +866,8 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -829,8 +866,8 @@ public class DefaultTimeBar extends View implements TimeBar {
int
playheadRadius
=
(
int
)
((
scrubberSize
*
scrubberScale
)
/
2
);
int
playheadRadius
=
(
int
)
((
scrubberSize
*
scrubberScale
)
/
2
);
canvas
.
drawCircle
(
playheadX
,
playheadY
,
playheadRadius
,
scrubberPaint
);
canvas
.
drawCircle
(
playheadX
,
playheadY
,
playheadRadius
,
scrubberPaint
);
}
else
{
}
else
{
int
scrubberDrawableWidth
=
scrubberDrawable
.
getIntrinsicWidth
(
);
int
scrubberDrawableWidth
=
(
int
)
(
scrubberDrawable
.
getIntrinsicWidth
()
*
scrubberScale
);
int
scrubberDrawableHeight
=
scrubberDrawable
.
getIntrinsicHeight
(
);
int
scrubberDrawableHeight
=
(
int
)
(
scrubberDrawable
.
getIntrinsicHeight
()
*
scrubberScale
);
scrubberDrawable
.
setBounds
(
scrubberDrawable
.
setBounds
(
playheadX
-
scrubberDrawableWidth
/
2
,
playheadX
-
scrubberDrawableWidth
/
2
,
playheadY
-
scrubberDrawableHeight
/
2
,
playheadY
-
scrubberDrawableHeight
/
2
,
...
...
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