-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[video_player] Implements background playback functionality #9212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
109813e
91e8818
b6d785a
8aa7279
776beac
748ad3b
62f035d
0a9f1b9
cca0a59
8faf122
dc0fd28
34e7af7
9d6abbf
92e48c9
fc9f99e
99c5ed9
5291126
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ public VideoPlayer( | |
exoPlayer.setMediaItem(mediaItem); | ||
exoPlayer.prepare(); | ||
exoPlayer.addListener(createExoPlayerEventListener(exoPlayer, surfaceProducer)); | ||
setAudioAttributes(exoPlayer, options.mixWithOthers); | ||
setAudioAttributes(exoPlayer, options.mixWithOthers, options.allowBackgroundPlayback); | ||
} | ||
|
||
@NonNull | ||
|
@@ -60,7 +60,11 @@ void sendBufferingUpdate() { | |
videoPlayerEvents.onBufferingUpdate(exoPlayer.getBufferedPosition()); | ||
} | ||
|
||
private static void setAudioAttributes(ExoPlayer exoPlayer, boolean isMixMode) { | ||
private static void setAudioAttributes( | ||
ExoPlayer exoPlayer, boolean isMixMode, boolean allowBackgroundPlayback) { | ||
if (allowBackgroundPlayback) { | ||
exoPlayer.setWakeMode(C.WAKE_MODE_NETWORK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs mention needing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh one more thing: We need a test for this in |
||
} | ||
exoPlayer.setAudioAttributes( | ||
new AudioAttributes.Builder().setContentType(C.AUDIO_CONTENT_TYPE_MOVIE).build(), | ||
!isMixMode); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
|
||
public class VideoPlayerOptions { | ||
public boolean mixWithOthers; | ||
public boolean allowBackgroundPlayback; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can you leave a comment here as to why
C.WAKE_MODE_NETWORK
is used here? It makes sense to me looking at the docs, but it may be useful for future reference :)