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
128ded5b
authored
May 16, 2019
by
bachinger
Committed by
Oliver Woodman
May 20, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add playWhenReady to prepareXyz methods of PlaybackPreparer.
Issue: #5891 PiperOrigin-RevId: 248541827
parent
92532d3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
32 deletions
RELEASENOTES.md
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java
RELEASENOTES.md
View file @
128ded5b
...
@@ -15,6 +15,10 @@
...
@@ -15,6 +15,10 @@
*
Add a workaround for broken raw audio decoding on Oppo R9
*
Add a workaround for broken raw audio decoding on Oppo R9
(
[
#5782
](
https://github.com/google/ExoPlayer/issues/5782
)
).
(
[
#5782
](
https://github.com/google/ExoPlayer/issues/5782
)
).
*
Offline: Add Scheduler implementation which uses WorkManager.
*
Offline: Add Scheduler implementation which uses WorkManager.
*
Add a playWhenReady flag to MediaSessionConnector.PlaybackPreparer methods
to indicate whether a controller sent a play or only a prepare command. This
allows to take advantage of decoder reuse with the MediaSessionConnector
(
[
#5891
](
https://github.com/google/ExoPlayer/issues/5891
)
).
### 2.10.1 ###
### 2.10.1 ###
...
...
extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java
View file @
128ded5b
...
@@ -172,7 +172,7 @@ public final class MediaSessionConnector {
...
@@ -172,7 +172,7 @@ public final class MediaSessionConnector {
ResultReceiver
cb
);
ResultReceiver
cb
);
}
}
/** Interface to which playback preparation actions are delegated. */
/** Interface to which playback preparation a
nd play a
ctions are delegated. */
public
interface
PlaybackPreparer
extends
CommandReceiver
{
public
interface
PlaybackPreparer
extends
CommandReceiver
{
long
ACTIONS
=
long
ACTIONS
=
...
@@ -197,14 +197,36 @@ public final class MediaSessionConnector {
...
@@ -197,14 +197,36 @@ public final class MediaSessionConnector {
* @return The bitmask of the supported media actions.
* @return The bitmask of the supported media actions.
*/
*/
long
getSupportedPrepareActions
();
long
getSupportedPrepareActions
();
/** See {@link MediaSessionCompat.Callback#onPrepare()}. */
/**
void
onPrepare
();
* See {@link MediaSessionCompat.Callback#onPrepare()}.
/** See {@link MediaSessionCompat.Callback#onPrepareFromMediaId(String, Bundle)}. */
*
void
onPrepareFromMediaId
(
String
mediaId
,
Bundle
extras
);
* @param playWhenReady Whether playback should be started after preparation.
/** See {@link MediaSessionCompat.Callback#onPrepareFromSearch(String, Bundle)}. */
*/
void
onPrepareFromSearch
(
String
query
,
Bundle
extras
);
void
onPrepare
(
boolean
playWhenReady
);
/** See {@link MediaSessionCompat.Callback#onPrepareFromUri(Uri, Bundle)}. */
/**
void
onPrepareFromUri
(
Uri
uri
,
Bundle
extras
);
* See {@link MediaSessionCompat.Callback#onPrepareFromMediaId(String, Bundle)}.
*
* @param mediaId The media id of the media item to be prepared.
* @param playWhenReady Whether playback should be started after preparation.
* @param extras A {@link Bundle} of extras passed by the media controller.
*/
void
onPrepareFromMediaId
(
String
mediaId
,
boolean
playWhenReady
,
Bundle
extras
);
/**
* See {@link MediaSessionCompat.Callback#onPrepareFromSearch(String, Bundle)}.
*
* @param query The search query.
* @param playWhenReady Whether playback should be started after preparation.
* @param extras A {@link Bundle} of extras passed by the media controller.
*/
void
onPrepareFromSearch
(
String
query
,
boolean
playWhenReady
,
Bundle
extras
);
/**
* See {@link MediaSessionCompat.Callback#onPrepareFromUri(Uri, Bundle)}.
*
* @param uri The {@link Uri} of the media item to be prepared.
* @param playWhenReady Whether playback should be started after preparation.
* @param extras A {@link Bundle} of extras passed by the media controller.
*/
void
onPrepareFromUri
(
Uri
uri
,
boolean
playWhenReady
,
Bundle
extras
);
}
}
/**
/**
...
@@ -834,12 +856,6 @@ public final class MediaSessionConnector {
...
@@ -834,12 +856,6 @@ public final class MediaSessionConnector {
return
player
!=
null
&&
mediaButtonEventHandler
!=
null
;
return
player
!=
null
&&
mediaButtonEventHandler
!=
null
;
}
}
private
void
setPlayWhenReady
(
boolean
playWhenReady
)
{
if
(
player
!=
null
)
{
controlDispatcher
.
dispatchSetPlayWhenReady
(
player
,
playWhenReady
);
}
}
private
void
rewind
(
Player
player
)
{
private
void
rewind
(
Player
player
)
{
if
(
player
.
isCurrentWindowSeekable
()
&&
rewindMs
>
0
)
{
if
(
player
.
isCurrentWindowSeekable
()
&&
rewindMs
>
0
)
{
seekTo
(
player
,
player
.
getCurrentPosition
()
-
rewindMs
);
seekTo
(
player
,
player
.
getCurrentPosition
()
-
rewindMs
);
...
@@ -1045,19 +1061,19 @@ public final class MediaSessionConnector {
...
@@ -1045,19 +1061,19 @@ public final class MediaSessionConnector {
if
(
canDispatchPlaybackAction
(
PlaybackStateCompat
.
ACTION_PLAY
))
{
if
(
canDispatchPlaybackAction
(
PlaybackStateCompat
.
ACTION_PLAY
))
{
if
(
player
.
getPlaybackState
()
==
Player
.
STATE_IDLE
)
{
if
(
player
.
getPlaybackState
()
==
Player
.
STATE_IDLE
)
{
if
(
playbackPreparer
!=
null
)
{
if
(
playbackPreparer
!=
null
)
{
playbackPreparer
.
onPrepare
();
playbackPreparer
.
onPrepare
(
/* playWhenReady= */
true
);
}
}
}
else
if
(
player
.
getPlaybackState
()
==
Player
.
STATE_ENDED
)
{
}
else
if
(
player
.
getPlaybackState
()
==
Player
.
STATE_ENDED
)
{
controlDispatcher
.
dispatchSeekTo
(
player
,
player
.
getCurrentWindowIndex
(),
C
.
TIME_UNSET
);
controlDispatcher
.
dispatchSeekTo
(
player
,
player
.
getCurrentWindowIndex
(),
C
.
TIME_UNSET
);
controlDispatcher
.
dispatchSetPlayWhenReady
(
player
,
/* playWhenReady= */
true
);
}
}
setPlayWhenReady
(
/* playWhenReady= */
true
);
}
}
}
}
@Override
@Override
public
void
onPause
()
{
public
void
onPause
()
{
if
(
canDispatchPlaybackAction
(
PlaybackStateCompat
.
ACTION_PAUSE
))
{
if
(
canDispatchPlaybackAction
(
PlaybackStateCompat
.
ACTION_PAUSE
))
{
setPlayWhenReady
(
/* playWhenReady= */
false
);
controlDispatcher
.
dispatchSetPlayWhenReady
(
player
,
/* playWhenReady= */
false
);
}
}
}
}
...
@@ -1180,56 +1196,49 @@ public final class MediaSessionConnector {
...
@@ -1180,56 +1196,49 @@ public final class MediaSessionConnector {
@Override
@Override
public
void
onPrepare
()
{
public
void
onPrepare
()
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE
))
{
setPlayWhenReady
(
/* playWhenReady= */
false
);
playbackPreparer
.
onPrepare
(
/* playWhenReady= */
false
);
playbackPreparer
.
onPrepare
();
}
}
}
}
@Override
@Override
public
void
onPrepareFromMediaId
(
String
mediaId
,
Bundle
extras
)
{
public
void
onPrepareFromMediaId
(
String
mediaId
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_MEDIA_ID
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_MEDIA_ID
))
{
setPlayWhenReady
(
/* playWhenReady= */
false
);
playbackPreparer
.
onPrepareFromMediaId
(
mediaId
,
/* playWhenReady= */
false
,
extras
);
playbackPreparer
.
onPrepareFromMediaId
(
mediaId
,
extras
);
}
}
}
}
@Override
@Override
public
void
onPrepareFromSearch
(
String
query
,
Bundle
extras
)
{
public
void
onPrepareFromSearch
(
String
query
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_SEARCH
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_SEARCH
))
{
setPlayWhenReady
(
/* playWhenReady= */
false
);
playbackPreparer
.
onPrepareFromSearch
(
query
,
/* playWhenReady= */
false
,
extras
);
playbackPreparer
.
onPrepareFromSearch
(
query
,
extras
);
}
}
}
}
@Override
@Override
public
void
onPrepareFromUri
(
Uri
uri
,
Bundle
extras
)
{
public
void
onPrepareFromUri
(
Uri
uri
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_URI
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PREPARE_FROM_URI
))
{
setPlayWhenReady
(
/* playWhenReady= */
false
);
playbackPreparer
.
onPrepareFromUri
(
uri
,
/* playWhenReady= */
false
,
extras
);
playbackPreparer
.
onPrepareFromUri
(
uri
,
extras
);
}
}
}
}
@Override
@Override
public
void
onPlayFromMediaId
(
String
mediaId
,
Bundle
extras
)
{
public
void
onPlayFromMediaId
(
String
mediaId
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_MEDIA_ID
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_MEDIA_ID
))
{
setPlayWhenReady
(
/* playWhenReady= */
true
);
playbackPreparer
.
onPrepareFromMediaId
(
mediaId
,
/* playWhenReady= */
true
,
extras
);
playbackPreparer
.
onPrepareFromMediaId
(
mediaId
,
extras
);
}
}
}
}
@Override
@Override
public
void
onPlayFromSearch
(
String
query
,
Bundle
extras
)
{
public
void
onPlayFromSearch
(
String
query
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_SEARCH
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_SEARCH
))
{
setPlayWhenReady
(
/* playWhenReady= */
true
);
playbackPreparer
.
onPrepareFromSearch
(
query
,
/* playWhenReady= */
true
,
extras
);
playbackPreparer
.
onPrepareFromSearch
(
query
,
extras
);
}
}
}
}
@Override
@Override
public
void
onPlayFromUri
(
Uri
uri
,
Bundle
extras
)
{
public
void
onPlayFromUri
(
Uri
uri
,
Bundle
extras
)
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_URI
))
{
if
(
canDispatchToPlaybackPreparer
(
PlaybackStateCompat
.
ACTION_PLAY_FROM_URI
))
{
setPlayWhenReady
(
/* playWhenReady= */
true
);
playbackPreparer
.
onPrepareFromUri
(
uri
,
/* playWhenReady= */
true
,
extras
);
playbackPreparer
.
onPrepareFromUri
(
uri
,
extras
);
}
}
}
}
...
...
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