Reputation: 1957
I'm developing app with video player using video_player 0.10.11+1
package.
while video player is playing i put my app in background. On AppLifecycleState.paused or AppLifecycleState.inactive
state after some time it was started playing in background.i was not getting how it started playing on background.so i have tried with didChangeAppLifecycleState
method on AppLifecycleState.paused
i made video controller pause. still after that also same it was happening.
This issue was happens in Redmi & OnePlus mobiles
Case,
step 1 : while video player is playing i put my app background.
step 2 : then i opened whatsapp,facebook other apps in my phone.
step 3 : after some time video player of my app which is in background mode started playing without opening it.
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.paused) {
print("Video Player AppLifecycleState Paused");
if (_controller != null) {
_controller.pause().then((_) {});
}
}
}
so,help me out to slove this issue.
Thanks in advance.
Upvotes: 3
Views: 2952
Reputation: 10519
Play/pause state of videos played using video_player is automatically handled by the plugin. Background playback is set to false by default. If allowBackgroundPlayback in the VideoPlayerOptions
has been set to true, just make sure to set it to false.
Also, another possible cause of this issue is another media is being played in the background. This issue has been resolved.
Upvotes: 1