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
89908794
authored
Mar 15, 2019
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #5496 from szaboa:dev-v2-5040
PiperOrigin-RevId: 237412166
parents
3ea6d78e
eaf0d408
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
9 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/res/values/attrs.xml
library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java
View file @
89908794
...
@@ -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
;
...
@@ -242,13 +243,14 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -242,13 +243,14 @@ 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
();
fineScrubYThreshold
=
dpToPx
(
displayMetrics
,
FINE_SCRUB_Y_THRESHOLD_DP
);
density
=
displayMetrics
.
density
;
int
defaultBarHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_BAR_HEIGHT_DP
);
fineScrubYThreshold
=
dpToPx
(
density
,
FINE_SCRUB_Y_THRESHOLD_DP
);
int
defaultTouchTargetHeight
=
dpToPx
(
displayMetrics
,
DEFAULT_TOUCH_TARGET_HEIGHT_DP
);
int
defaultBarHeight
=
dpToPx
(
density
,
DEFAULT_BAR_HEIGHT_DP
);
int
defaultAdMarkerWidth
=
dpToPx
(
displayMetrics
,
DEFAULT_AD_MARKER_WIDTH_DP
);
int
defaultTouchTargetHeight
=
dpToPx
(
density
,
DEFAULT_TOUCH_TARGET_HEIGHT_DP
);
int
defaultScrubberEnabledSize
=
dpToPx
(
displayMetrics
,
DEFAULT_SCRUBBER_ENABLED_SIZE_DP
);
int
defaultAdMarkerWidth
=
dpToPx
(
density
,
DEFAULT_AD_MARKER_WIDTH_DP
);
int
defaultScrubberDisabledSize
=
dpToPx
(
displayMetrics
,
DEFAULT_SCRUBBER_DISABLED_SIZE_DP
);
int
defaultScrubberEnabledSize
=
dpToPx
(
density
,
DEFAULT_SCRUBBER_ENABLED_SIZE_DP
);
int
defaultScrubberDraggedSize
=
dpToPx
(
displayMetrics
,
DEFAULT_SCRUBBER_DRAGGED_SIZE_DP
);
int
defaultScrubberDisabledSize
=
dpToPx
(
density
,
DEFAULT_SCRUBBER_DISABLED_SIZE_DP
);
int
defaultScrubberDraggedSize
=
dpToPx
(
density
,
DEFAULT_SCRUBBER_DRAGGED_SIZE_DP
);
if
(
attrs
!=
null
)
{
if
(
attrs
!=
null
)
{
TypedArray
a
=
context
.
getTheme
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DefaultTimeBar
,
0
,
TypedArray
a
=
context
.
getTheme
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DefaultTimeBar
,
0
,
0
);
0
);
...
@@ -437,6 +439,14 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -437,6 +439,14 @@ public class DefaultTimeBar extends View implements TimeBar {
}
}
@Override
@Override
public
long
getPreferredUpdateDelay
()
{
int
timeBarWidthDp
=
pxToDp
(
density
,
progressBar
.
width
());
return
timeBarWidthDp
==
0
||
duration
==
0
||
duration
==
C
.
TIME_UNSET
?
Long
.
MAX_VALUE
:
duration
/
timeBarWidthDp
;
}
@Override
public
void
setAdGroupTimesMs
(
@Nullable
long
[]
adGroupTimesMs
,
@Nullable
boolean
[]
playedAdGroups
,
public
void
setAdGroupTimesMs
(
@Nullable
long
[]
adGroupTimesMs
,
@Nullable
boolean
[]
playedAdGroups
,
int
adGroupCount
)
{
int
adGroupCount
)
{
Assertions
.
checkArgument
(
adGroupCount
==
0
Assertions
.
checkArgument
(
adGroupCount
==
0
...
@@ -832,7 +842,11 @@ public class DefaultTimeBar extends View implements TimeBar {
...
@@ -832,7 +842,11 @@ public class DefaultTimeBar extends View implements TimeBar {
return
0x33000000
|
(
adMarkerColor
&
0x00FFFFFF
);
return
0x33000000
|
(
adMarkerColor
&
0x00FFFFFF
);
}
}
private
static
int
dpToPx
(
DisplayMetrics
displayMetrics
,
int
dps
)
{
private
static
int
dpToPx
(
float
density
,
int
dps
)
{
return
(
int
)
(
dps
*
displayMetrics
.
density
+
0.5f
);
return
(
int
)
(
dps
*
density
+
0.5f
);
}
private
static
int
pxToDp
(
float
density
,
int
px
)
{
return
(
int
)
(
px
/
density
);
}
}
}
}
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java
View file @
89908794
This diff is collapsed.
Click to expand it.
library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java
View file @
89908794
...
@@ -85,6 +85,14 @@ public interface TimeBar {
...
@@ -85,6 +85,14 @@ public interface TimeBar {
void
setDuration
(
long
duration
);
void
setDuration
(
long
duration
);
/**
/**
* Returns the preferred delay in milliseconds of media time after which the time bar position
* should be updated.
*
* @return Preferred delay, in milliseconds of media time.
*/
long
getPreferredUpdateDelay
();
/**
* Sets the times of ad groups and whether each ad group has been played.
* Sets the times of ad groups and whether each ad group has been played.
*
*
* @param adGroupTimesMs An array where the first {@code adGroupCount} elements are the times of
* @param adGroupTimesMs An array where the first {@code adGroupCount} elements are the times of
...
...
library/ui/src/main/res/values/attrs.xml
View file @
89908794
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
<flag
name=
"all"
value=
"2"
/>
<flag
name=
"all"
value=
"2"
/>
</attr>
</attr>
<attr
name=
"show_shuffle_button"
format=
"boolean"
/>
<attr
name=
"show_shuffle_button"
format=
"boolean"
/>
<attr
name=
"time_bar_min_update_interval"
format=
"integer"
/>
<declare-styleable
name=
"PlayerView"
>
<declare-styleable
name=
"PlayerView"
>
<attr
name=
"use_artwork"
format=
"boolean"
/>
<attr
name=
"use_artwork"
format=
"boolean"
/>
...
@@ -66,6 +67,7 @@
...
@@ -66,6 +67,7 @@
<attr
name=
"fastforward_increment"
/>
<attr
name=
"fastforward_increment"
/>
<attr
name=
"repeat_toggle_modes"
/>
<attr
name=
"repeat_toggle_modes"
/>
<attr
name=
"show_shuffle_button"
/>
<attr
name=
"show_shuffle_button"
/>
<attr
name=
"time_bar_min_update_interval"
/>
<attr
name=
"controller_layout_id"
/>
<attr
name=
"controller_layout_id"
/>
</declare-styleable>
</declare-styleable>
...
@@ -79,6 +81,7 @@
...
@@ -79,6 +81,7 @@
<attr
name=
"fastforward_increment"
/>
<attr
name=
"fastforward_increment"
/>
<attr
name=
"repeat_toggle_modes"
/>
<attr
name=
"repeat_toggle_modes"
/>
<attr
name=
"show_shuffle_button"
/>
<attr
name=
"show_shuffle_button"
/>
<attr
name=
"time_bar_min_update_interval"
/>
<attr
name=
"controller_layout_id"
/>
<attr
name=
"controller_layout_id"
/>
</declare-styleable>
</declare-styleable>
...
...
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