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

Bug with play button #36

Open
CharlesOnAir opened this issue Oct 4, 2020 · 5 comments
Open

Bug with play button #36

CharlesOnAir opened this issue Oct 4, 2020 · 5 comments

Comments

@CharlesOnAir
Copy link

Hello,

I am using your plugin for my application, at the moment I am having two problems.

The first is that I can't change the state of the play button, it is always displayed in play.

The second is when I decided to close my iOs to test the player from the lockscreen, my player disappears to display a pleasure with only "Ionic App" for information.

Thanks for your help !

@ghenry22
Copy link
Owner

Have a look at issue #39

Make sure you are using the cordova media plugin for your audio playback. HTML5 audio tag overrides the metadata with the html file name. This has always been the case, there doesn't seem to be a way to stop it doing this.

@sam4593
Copy link

sam4593 commented Jun 1, 2021

I am using your plugin in my app for IOS but Play button status does not changes. @ghenry22

I have followed all the mentioned instructions and I am using media plugin and not using any background plugin.
I can't change the state of the play button, it is always displayed in play.

@sam4593
Copy link

sam4593 commented Jun 1, 2021

HERE IS MY CODE

this.pltform.ready().then(() => {
this.settingMusicControl();
this.initMedia();
}), err => {
alert(JSON.stringify( err));
}
}

play() {
this.file.play();
console.log('play');
this.musicControls.updateIsPlaying(true);
this.musicControls.updateDismissable(false);

}
pause(){
this.file.pause();
this.musicControls.updateIsPlaying(false);
this.musicControls.updateDismissable(true);
}
initMedia(){
this.file = this.media.create('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3');
this.file.onStatusUpdate.subscribe(status => console.log(status)); // fires when file status changes

this.file.onSuccess.subscribe(() => console.log('Action is successful'));

this.file.onError.subscribe(error => console.log('Error!', error));

}

settingMusicControl(){

this.musicControls.create({
  track       : 'Test track',       
  artist      : 'test artist',                    
  cover       : '',      // optional, default : nothing
 
  isPlaying   : true,                         // optional, default : true
  dismissable : true,                         // optional, default : false

  hasPrev   : false,      // show previous button, optional, default: true
  hasNext   : false,      // show next button, optional, default: true
  hasClose  : true,      
  hasSkipForward : true,  
  hasSkipBackward : true, 
  skipForwardInterval: 15, 
  skipBackwardInterval: 15, 

  album       : 'test album',    
  duration : 60, 
  elapsed : 60, 

  ticker    : 'Now playing test'
 });
 this.musicControls.subscribe().subscribe((action) => {
  console.log('action', action);
      const message = JSON.parse(action).message;
      console.log('message', message);
      switch(message) {
        case 'music-controls-next':
           // Do something
           break;
        case 'music-controls-previous':
           // Do something
           break;
        case 'music-controls-pause':
           // Do something
           console.log('music pause');
           this.file.pause();
           this.musicControls.listen(); 
           this.musicControls.updateIsPlaying(false);
           this.musicControls.updateDismissable(true);
           break;
        case 'music-controls-play':
           // Do something
           console.log('music play');
           this.file.play();
           this.musicControls.listen(); 
           this.musicControls.updateIsPlaying(true);
           this.musicControls.updateDismissable(false);
           break;
        case 'music-controls-destroy':
           // Do something
           break;
        // External controls (iOS only)
        case 'music-controls-toggle-play-pause' :
          // Do something
          break;
        case 'music-controls-seek-to':
          // Do something
          break;
        case 'music-controls-skip-forward':
          // Do something
          break;
        case 'music-controls-skip-backward':
          // Do something
          break;

        default:
            break;
      }
});
this.musicControls.listen(); // activates the observable above
this.musicControls.updateIsPlaying(false);

}

@sam4593
Copy link

sam4593 commented Jun 18, 2021

Does any one can answer the above mentioned issue for ios???

@sam4593
Copy link

sam4593 commented Jun 18, 2021

@ghenry22 @CharlesOnAir Please need assistance

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

3 participants