ghenry22 / cordova-plugin-music-controls2

A Cordova plugin displaying music controls in notifications (cordova-plugin-music-controls)
MIT License
59 stars 60 forks source link

Lock Screen Buttons not working on Samsung Devices with android 10+ #63

Closed leobaccili closed 3 years ago

leobaccili commented 3 years ago

Hello. Buttons on lock screen not working properly. Pause won't fire and prev/next is visible but i set to false.

givethanks1 commented 3 years ago

Buttons on lock screen work on lock screen for me (tested on Samsung devices with Android 10). Did you subscribe to events & begin the listen process in your code as well?

The Prev/Next issue was previously observed: https://github.com/ghenry22/cordova-plugin-music-controls2/issues/58

leobaccili commented 3 years ago

Buttons on lock screen work on lock screen for me (tested on Samsung devices with Android 10). Did you subscribe to events & begin the listen process in your code as well?

The Prev/Next issue was previously observed: #58

Yes, the code working on my device, on emulators but dont work on Samsung devices.

ghenry22 commented 3 years ago

Works perfect on Samsung device with Android 11 for me. Unfortunately that's the only test device that I have.

What events are you listening for to catch play/pause?

leobaccili commented 3 years ago

https://developer.samsung.com/remotetestlab/galaxy/rtlDeviceList.action I use this to test

leobaccili commented 3 years ago

Take a look: https://youtu.be/Syqfy1L09IM

This is my code:

MusicControls.create({ cover: 'assets/imgs/icon.png', track: 'Ao vivo!', artist: 'Tabelando', dismissable: true, hasScrubbing: false, playIcon: 'media_play', pauseIcon: 'media_pause', prevIcon: 'media_prev', nextIcon: 'media_next', closeIcon: 'media_close', notificationIcon: 'notification', isPlaying: false, hasNext: false, hasPrev: false, });

  MusicControls.updateIsPlaying(false);
  MusicControls.subscribe((action) => {
    console.log(action);
    const message = JSON.parse(action).message;
    switch (message) {
      case 'music-controls-pause':
        this.pauseAudio();
        break;
      case 'music-controls-play':
        this.playAudioAgain(true);
        break;
      case 'music-controls-destroy':
        this.platform.exitApp();
        break;
      case 'music-controls-toggle-play-pause':
        this.playAudioAgain(true);
        break;
      default:
        break;
    }
  });
  MusicControls.listen(); 

Ionic:

Ionic CLI : 6.13.1 (C:\Users\leobaccili\AppData\Roaming\npm\node_modules\@ionic\cli) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.1

Cordova:

Cordova CLI : 10.0.0 Cordova Platforms : android 9.1.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)

Utility:

cordova-res (update available: 0.15.3) : 0.15.2 native-run (update available: 1.3.0) : 0.2.2

System:

Android SDK Tools : 26.1.1 (H:\Android\sdk) NodeJS : v12.19.0 (H:\nodejs\node.exe) npm : 6.14.8 OS : Windows 10

NorthFred commented 3 years ago

Hopefully this answer comes in time, subscribing is done in this way: this.musicControls.subscribe().subscribe(action => { .......

Source: https://ionicframework.com/docs/native/music-controls

gvorster commented 2 years ago

I had the same issue on my Samsung Galaxy A41, Android 11. I am using Quasar/Vue framework+Cordova Android 10.1.2

I needed to install the cordova-plugin-background-mode plugin. After that the buttons on the lock screen are working fine and the app is receiving the events.