tanguyantoine / react-native-music-control

Display and manage media controls on lock screen and notification center for iOS and Android.
https://www.npmjs.com/package/react-native-music-control
MIT License
697 stars 264 forks source link

Music control close notification does not work #333

Open akk7300 opened 4 years ago

akk7300 commented 4 years ago

I added MusicControl.enableControl('closeNotification', true, {when: 'always'}) but it does not work.

Other buttons work fine correctly.

bradfloodx commented 4 years ago

Hi @akk7300 If you can provide an example of how to simulate this issue I'm happy to look into it.

Thanks.

akk7300 commented 4 years ago

`constructor(props) {

super(props);
this.state = { }
MusicControl.enableControl('play', true);
MusicControl.enableControl('pause', true);
MusicControl.enableControl('nextTrack', true)
MusicControl.enableControl('previousTrack', true)
MusicControl.enableControl('closeNotification', true, {when: 'always'})

}

componentDidMount(){

MusicControl.on('play', ()=> {
  this.playControl();
})

MusicControl.on('pause', ()=> {
  this.PauseControl();
})

MusicControl.on('nextTrack', ()=> {

  this.NextControl();
})

MusicControl.on('previousTrack', ()=> {
  this.previousControl();
})

MusicControl.on('closeNotification',()=>{
  this.closeNotiControl();
})

}`

Play Pause Next and Previous Button show in notification and can control But close notification on swipe not working

bradfloodx commented 4 years ago

Ok thanks @akk7300 so this is just the default closeNotification event. I'll have a look into it.

HasanAlyazidi commented 4 years ago

Closing notifications works on android 7, but it does not work on android 10 (did not test android 8 and 9)

HasanAlyazidi commented 4 years ago

Notification does not close at all on android. (Tested on android 7+)

HasanAlyazidi commented 4 years ago

Here is a GIF

Tested ^0.12.0

7-6877b83fa58b

Joshmatjjen commented 3 years ago

Same here, why hasn't this been resolved yet ?

Joshmatjjen commented 3 years ago

I just fixed it... first, run this script to install this version:
If using NPM npm i react-native-music-control@0.10.8

If using Yarn

yarn add react-native-music-control@0.10.8

This is an example of the code i used

if (state.pause === true) { MusicControl.updatePlayback({ state: MusicControl.STATE_PAUSED, }); // Make your choice with any of this functions MusicControl.enableControl('closeNotification', true, { when: 'paused' }); MusicControl.enableControl('closeNotification', true, { when: 'always' }); MusicControl.stopControl(); }

Hope this could help anyone out there

HasanAlyazidi commented 3 years ago

@Joshmatjjen still not fixed

HasanAlyazidi commented 3 years ago

Hi @Joshmatjjen

Closing the notification on swipe works on v0.10.8 and v0.11.0, BUT the notification is blank on android 5.0

Screenshot_1602919987

v0.12.0 = blank notification and does not close on swipe or calling MusicControl.resetNowPlaying(); and MusicControl.stopControl();

v1.2.1 = notification looks right but does not close on swipe or calling MusicControl.resetNowPlaying(); and MusicControl.stopControl();

Joshmatjjen commented 3 years ago

@HasanAlyazidi Have you tired changing the min-sdk version to 16 or 17 in your build.gradle...

If it dont work, You have to create your app to only andriod greater than 5.0

cstranex commented 3 years ago

Any progress on fixing this?

akk7300 commented 3 years ago

I used stop button for close notification.

krunalbad commented 3 years ago

I am also facing this issue