Skip to content
This repository has been archived by the owner on Nov 22, 2020. It is now read-only.

music not stop when removing app from background #6

Open
HetalGohil opened this issue Dec 23, 2019 · 8 comments
Open

music not stop when removing app from background #6

HetalGohil opened this issue Dec 23, 2019 · 8 comments
Labels
bug Something isn't working

Comments

@HetalGohil
Copy link

HetalGohil commented Dec 23, 2019

i m using this library for media notification and audioplayers library for song play when i play song then i have set notification using setNotification method..music play in background perfectly bt when i remove app from home button directly(from recent apps) without back press,music play in background continuosly ..without using this library music stop when i am removing it from background but with this library it not working.

@ranjannisha
Copy link

Same problem here. Media Notification Pause Button doesn't work when app is closed. Should be able to pass some arguments on callback of MediaNotification.setListener('pause', callback);

@aliyazdi75
Copy link
Owner

@ranjannisha
We have 2 ways app running on background, 1st with middle key and app is running on background and notification is works in this situation. 2nd with back key and app is not running on background but I'm working on it to fix this problem.

@aliyazdi75 aliyazdi75 added the bug Something isn't working label Feb 1, 2020
@inartin
Copy link

inartin commented Feb 9, 2020

Any updates here ?

@bubbleis
Copy link

Hello there @aliyazdi75, can you provide an update here please?

@inartin
Copy link

inartin commented Feb 27, 2020

I have found a temporary solution for this situation.

Use AppLifecycleState.paused event and set MediaNotification.hideNotification() in that event and
when .resumed set it to .ShowNotfication again

it is not perfect because when user opens other app or exit to home screen, the notification is hidden but music continues to play.
However when the app is killed (removed from background) the notification is closed and music stops and that's what we needed.

void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: MediaNotification.showNotification( title: Player.currentTrack?.title ?? 'Title', author: Player.currentTrack?.artist?.name ?? 'Author', isPlaying: Player.isPlaying, ); break; case AppLifecycleState.paused: MediaNotification.hideNotification(); break; default: break; } }

@fracon
Copy link

fracon commented Apr 18, 2020

@aliyazdi75 Do you have an idea of when we will have a fix for this issue?

@aliyazdi75
Copy link
Owner

@fracon yes, we have to use isolate and I'm working on it.

@muratkryc
Copy link

Use this
@OverRide
protected void onDestroy() {
super.onDestroy();
android.os.Process.killProcess(android.os.Process.myPid());
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants