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

fails to implement solution on ios #98

Open urbilog opened 1 year ago

urbilog commented 1 year ago

Hi. I’m currently working on a recently updated Ionic app. It’s currently in IONIC 6 version. I have to add some custom controls on earbuds input. According to the documentation (https://ionicframework.com/docs/v5/native/music-controls) it is possible with music control (https://github.com/ghenry22/cordova-plugin-music-controls2). I’ve tried on Android and it work perfectly ! But I can’t manage to trigger any earbud event on IOS. I saw that the ionic documentation for music control is for Ionic v5. I asked on the Ionic Discord if it is still available for Ionic v6 they said it should be but I should ask here. I wondered that the problem could be linked to my app, so I just created a blank app but still no event triggered on iOS.

home.page.ts ` import { Component } from '@angular/core'; import { MusicControls } from '@awesome-cordova-plugins/music-controls/ngx';

@Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage {

constructor(private musicControls: MusicControls) {}

ngOnInit() {

this.musicControls.create({
  hasPrev: false,
  hasNext: false,
  isPlaying: false
});
this.musicControls.subscribe().subscribe(action => {
  const message = JSON.parse(action).message
  console.log('1', JSON.parse(action))
  console.log('2', message)

  if(message === 'music-controls-toggle-play-pause') {
    console.log('IOS PLAY/PAUSE')
  }
  if(message === 'music-controls-toggle-play') {
    console.log('IOS PLAY')
  }
  if(message === 'music-controls-toggle-pause') {
    console.log('IOS PAUSE')
  }
  if(message === 'music-controls-media-button-play-pause') {
    console.log('ANDROID PLAY/PAUSE')
  }
  if(message === 'music-controls-media-button-play') {
    console.log('ANDROID PLAY')
  }
  if(message === 'music-controls-media-button-pause') {
    console.log('ANDROID PAUSE')
  }
})
this.musicControls.listen();

}

ngOnDestroy() { this.musicControls.destroy(); } } `