Playing the video in background while activity is stopped
See original GitHub issueHello, thanks again for this wonderful library!
Maybe I’m missing something but the player continues playing in the background when I press the home button or open another activity. It happens sometimes only when the video is not loaded yet even when mYouTubePlayer.pause(); is called in the onPause method.
Here is what I do :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
ButterKnife.bind(this);
mVideo = (Video) getIntent().getSerializableExtra(Constant.INTENT_OBJECT);
mVideoActivity = (VideoAct) getIntent().getSerializableExtra(Constant.INTENT_ACTIVITY);
initYoutubePlayer();
}
private void initYoutubePlayer() {
getLifecycle().addObserver(youtubePlayerView);
youtubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
@Override
public void onReady(@NonNull YouTubePlayer youTubePlayer) {
mYouTubePlayer = youTubePlayer;
int startTime = 0;
if (mVideoActivity != null) {
startTime = mVideoActivity.timeCode;
}
YouTubePlayerUtils.loadOrCueVideo(mYouTubePlayer, getLifecycle(), videoKey, startTime);
}
});
}
@Override
public void onPause() {
super.onPause();
if (mYouTubePlayer != null) {
mYouTubePlayer.pause();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
youtubePlayerView.release();
}
Thanks in advance
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
android - How to stop playing video when Parent Activity is in ...
I have recently tried to use ExoPlayer from google in my android project. Exoplayer is keep playing video even I have call all...
Read more >Restrictions on starting activities from the background
Android 10 (API level 29) and higher place restrictions on when apps can start activities when the app is running in the background....
Read more >Can't update Live Activity from ap… | Apple Developer Forums
Can't update Live Activity from app with ActivityKit when app is running in the background with background audio playing.
Read more >Turn on background data - Google Play Help
Turn on background data · Open your device's Settings app . · Tap Network & internet. · Tap Data usage and then ·...
Read more >Windows background apps and your privacy - Microsoft Support
Stop an app from running in the background ... If you don't want to get notifications or updates for an app when you're...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, thank YOU for your help. I can’t reproduce it anymore! 😃
Bug fixed in version 10.0.2! thank you for the help 😃