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
46687fec
authored
Jun 02, 2021
by
bachinger
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow fast forward and rewind actions in compact view
PiperOrigin-RevId: 377107132
parent
d515e2c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
7 deletions
RELEASENOTES.md
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
RELEASENOTES.md
View file @
46687fec
...
@@ -66,6 +66,9 @@
...
@@ -66,6 +66,9 @@
*
PlayerNotificationManager:
*
PlayerNotificationManager:
*
Add
`PendingIntent.FLAG_IMMUTABLE`
flag to BroadcastReceiver to support
*
Add
`PendingIntent.FLAG_IMMUTABLE`
flag to BroadcastReceiver to support
Android 12.
Android 12.
*
Add
`setUseFastForwardActionInCompactView(boolean)`
and
`setUseRewindActionInCompactView(boolean)`
to make it possible to show
seek actions in compact view mode.
*
DRM:
*
DRM:
*
Don't restore offline keys before releasing them. In OEMCrypto v16+ keys
*
Don't restore offline keys before releasing them. In OEMCrypto v16+ keys
must be released without restoring them first.
must be released without restoring them first.
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java
View file @
46687fec
...
@@ -91,12 +91,24 @@ import java.util.Map;
...
@@ -91,12 +91,24 @@ import java.util.Map;
* <li>Corresponding setter: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Corresponding setter: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_REWIND_MS} (5000)
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_REWIND_MS} (5000)
* </ul>
* </ul>
* <li><b>{@code useRewindActionInCompactView}</b> - Sets whether the rewind action should be
* shown in compact view mode.
* <ul>
* <li>Corresponding setter: {@link #setUseRewindActionInCompactView(boolean)}
* <li>Default: {@code false}
* </ul>
* <li><b>{@code fastForwardIncrementMs}</b> - Sets the fast forward increment. If set to zero the
* <li><b>{@code fastForwardIncrementMs}</b> - Sets the fast forward increment. If set to zero the
* fast forward action is not used.
* fast forward action is not used.
* <ul>
* <ul>
* <li>Corresponding setter: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Corresponding setter: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_FAST_FORWARD_MS} (15000)
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_FAST_FORWARD_MS} (15000)
* </ul>
* </ul>
* <li><b>{@code useFastForwardActionInCompactView}</b> - Sets whether the fast forward action
* should be shown in compact view mode.
* <ul>
* <li>Corresponding setter: {@link #setUseFastForwardActionInCompactView(boolean)}
* <li>Default: {@code false}
* </ul>
* <li><b>{@code usePreviousAction}</b> - Whether the previous action is used.
* <li><b>{@code usePreviousAction}</b> - Whether the previous action is used.
* <ul>
* <ul>
* <li>Corresponding setter: {@link #setUsePreviousAction(boolean)}
* <li>Corresponding setter: {@link #setUsePreviousAction(boolean)}
...
@@ -647,6 +659,8 @@ public class PlayerNotificationManager {
...
@@ -647,6 +659,8 @@ public class PlayerNotificationManager {
private
boolean
useNextAction
;
private
boolean
useNextAction
;
private
boolean
usePreviousActionInCompactView
;
private
boolean
usePreviousActionInCompactView
;
private
boolean
useNextActionInCompactView
;
private
boolean
useNextActionInCompactView
;
private
boolean
useRewindActionInCompactView
;
private
boolean
useFastForwardActionInCompactView
;
private
boolean
usePlayPauseActions
;
private
boolean
usePlayPauseActions
;
private
boolean
useStopAction
;
private
boolean
useStopAction
;
private
int
badgeIconType
;
private
int
badgeIconType
;
...
@@ -808,11 +822,17 @@ public class PlayerNotificationManager {
...
@@ -808,11 +822,17 @@ public class PlayerNotificationManager {
* also be used in compact view. Has no effect if {@link #setUseNextAction useNextAction} is
* also be used in compact view. Has no effect if {@link #setUseNextAction useNextAction} is
* {@code false}.
* {@code false}.
*
*
* <p>If set to {@code true}, {@link #setUseFastForwardActionInCompactView(boolean)
* setUseFastForwardActionInCompactView} is set to false.
*
* @param useNextActionInCompactView Whether to use the next action in compact view.
* @param useNextActionInCompactView Whether to use the next action in compact view.
*/
*/
public
void
setUseNextActionInCompactView
(
boolean
useNextActionInCompactView
)
{
public
void
setUseNextActionInCompactView
(
boolean
useNextActionInCompactView
)
{
if
(
this
.
useNextActionInCompactView
!=
useNextActionInCompactView
)
{
if
(
this
.
useNextActionInCompactView
!=
useNextActionInCompactView
)
{
this
.
useNextActionInCompactView
=
useNextActionInCompactView
;
this
.
useNextActionInCompactView
=
useNextActionInCompactView
;
if
(
useNextActionInCompactView
)
{
useFastForwardActionInCompactView
=
false
;
}
invalidate
();
invalidate
();
}
}
}
}
...
@@ -822,11 +842,56 @@ public class PlayerNotificationManager {
...
@@ -822,11 +842,56 @@ public class PlayerNotificationManager {
* action should also be used in compact view. Has no effect if {@link #setUsePreviousAction
* action should also be used in compact view. Has no effect if {@link #setUsePreviousAction
* usePreviousAction} is {@code false}.
* usePreviousAction} is {@code false}.
*
*
* <p>If set to {@code true}, {@link #setUseRewindActionInCompactView(boolean)
* setUseRewindActionInCompactView} is set to false.
*
* @param usePreviousActionInCompactView Whether to use the previous action in compact view.
* @param usePreviousActionInCompactView Whether to use the previous action in compact view.
*/
*/
public
void
setUsePreviousActionInCompactView
(
boolean
usePreviousActionInCompactView
)
{
public
void
setUsePreviousActionInCompactView
(
boolean
usePreviousActionInCompactView
)
{
if
(
this
.
usePreviousActionInCompactView
!=
usePreviousActionInCompactView
)
{
if
(
this
.
usePreviousActionInCompactView
!=
usePreviousActionInCompactView
)
{
this
.
usePreviousActionInCompactView
=
usePreviousActionInCompactView
;
this
.
usePreviousActionInCompactView
=
usePreviousActionInCompactView
;
if
(
usePreviousActionInCompactView
)
{
useRewindActionInCompactView
=
false
;
}
invalidate
();
}
}
/**
* Sets whether the fast forward action should also be used in compact view. Has no effect if
* {@link #ACTION_FAST_FORWARD} is not enabled, for instance if the media is not seekable.
*
* <p>If set to {@code true}, {@link #setUseNextActionInCompactView(boolean)
* setUseNextActionInCompactView} is set to false.
*
* @param useFastForwardActionInCompactView Whether to use the fast forward action in compact
* view.
*/
public
void
setUseFastForwardActionInCompactView
(
boolean
useFastForwardActionInCompactView
)
{
if
(
this
.
useFastForwardActionInCompactView
!=
useFastForwardActionInCompactView
)
{
this
.
useFastForwardActionInCompactView
=
useFastForwardActionInCompactView
;
if
(
useFastForwardActionInCompactView
)
{
useNextActionInCompactView
=
false
;
}
invalidate
();
}
}
/**
* Sets whether the rewind action should also be used in compact view. Has no effect if {@link
* #ACTION_REWIND} is not enabled, for instance if the media is not seekable.
*
* <p>If set to {@code true}, {@link #setUsePreviousActionInCompactView(boolean)
* setUsePreviousActionInCompactView} is set to false.
*
* @param useRewindActionInCompactView Whether to use the rewind action in compact view.
*/
public
void
setUseRewindActionInCompactView
(
boolean
useRewindActionInCompactView
)
{
if
(
this
.
useRewindActionInCompactView
!=
useRewindActionInCompactView
)
{
this
.
useRewindActionInCompactView
=
useRewindActionInCompactView
;
if
(
useRewindActionInCompactView
)
{
usePreviousActionInCompactView
=
false
;
}
invalidate
();
invalidate
();
}
}
}
}
...
@@ -1255,14 +1320,19 @@ public class PlayerNotificationManager {
...
@@ -1255,14 +1320,19 @@ public class PlayerNotificationManager {
protected
int
[]
getActionIndicesForCompactView
(
List
<
String
>
actionNames
,
Player
player
)
{
protected
int
[]
getActionIndicesForCompactView
(
List
<
String
>
actionNames
,
Player
player
)
{
int
pauseActionIndex
=
actionNames
.
indexOf
(
ACTION_PAUSE
);
int
pauseActionIndex
=
actionNames
.
indexOf
(
ACTION_PAUSE
);
int
playActionIndex
=
actionNames
.
indexOf
(
ACTION_PLAY
);
int
playActionIndex
=
actionNames
.
indexOf
(
ACTION_PLAY
);
int
previousActionIndex
=
int
leftSideActionIndex
=
usePreviousActionInCompactView
?
actionNames
.
indexOf
(
ACTION_PREVIOUS
)
:
-
1
;
usePreviousActionInCompactView
int
nextActionIndex
=
useNextActionInCompactView
?
actionNames
.
indexOf
(
ACTION_NEXT
)
:
-
1
;
?
actionNames
.
indexOf
(
ACTION_PREVIOUS
)
:
(
useRewindActionInCompactView
?
actionNames
.
indexOf
(
ACTION_REWIND
)
:
-
1
);
int
rightSideActionIndex
=
useNextActionInCompactView
?
actionNames
.
indexOf
(
ACTION_NEXT
)
:
(
useFastForwardActionInCompactView
?
actionNames
.
indexOf
(
ACTION_FAST_FORWARD
)
:
-
1
);
int
[]
actionIndices
=
new
int
[
3
];
int
[]
actionIndices
=
new
int
[
3
];
int
actionCounter
=
0
;
int
actionCounter
=
0
;
if
(
previous
ActionIndex
!=
-
1
)
{
if
(
leftSide
ActionIndex
!=
-
1
)
{
actionIndices
[
actionCounter
++]
=
previous
ActionIndex
;
actionIndices
[
actionCounter
++]
=
leftSide
ActionIndex
;
}
}
boolean
shouldShowPauseButton
=
shouldShowPauseButton
(
player
);
boolean
shouldShowPauseButton
=
shouldShowPauseButton
(
player
);
if
(
pauseActionIndex
!=
-
1
&&
shouldShowPauseButton
)
{
if
(
pauseActionIndex
!=
-
1
&&
shouldShowPauseButton
)
{
...
@@ -1270,8 +1340,8 @@ public class PlayerNotificationManager {
...
@@ -1270,8 +1340,8 @@ public class PlayerNotificationManager {
}
else
if
(
playActionIndex
!=
-
1
&&
!
shouldShowPauseButton
)
{
}
else
if
(
playActionIndex
!=
-
1
&&
!
shouldShowPauseButton
)
{
actionIndices
[
actionCounter
++]
=
playActionIndex
;
actionIndices
[
actionCounter
++]
=
playActionIndex
;
}
}
if
(
next
ActionIndex
!=
-
1
)
{
if
(
rightSide
ActionIndex
!=
-
1
)
{
actionIndices
[
actionCounter
++]
=
next
ActionIndex
;
actionIndices
[
actionCounter
++]
=
rightSide
ActionIndex
;
}
}
return
Arrays
.
copyOf
(
actionIndices
,
actionCounter
);
return
Arrays
.
copyOf
(
actionIndices
,
actionCounter
);
}
}
...
...
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