Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to implement solution on ios #98

Open
urbilog opened this issue Aug 17, 2023 · 0 comments
Open

fails to implement solution on ios #98

urbilog opened this issue Aug 17, 2023 · 0 comments

Comments

@urbilog
Copy link

urbilog commented Aug 17, 2023

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();
}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant