notifaction bar controls issue
BilalAdhi opened this issue · 1 comments
BilalAdhi commented
Kindly help me out with this not sure if i'm doing something wrong because i even copy pasted the code but it's events are still not getting subscribed when triggered in the notification's bar.
please do let me know if there's some sort of glitch in the plugin or in my code. would really appreciate your help.
this.musicControls.destroy();
console.log("showMp3Player");
this.musicControls.create({
track : this._SurahNameArabic,
artist : this._SurahName,
// cover : 'albums/absolution.jpg',
isPlaying : true,
dismissable : true,
hasPrev : true,
hasNext : true,
hasClose : true,
});
this.musicControls.subscribe().subscribe((action) => {
const message = JSON.parse(action).message;
console.log('action', action);
console.log(message);
console.log("testing event");
switch(message) {
case 'music-controls-next':
console.log('music-controls-next')
// Do something
break;
case 'music-controls-previous':
console.log('music-controls-previous')
// Do something
break;
case 'music-controls-pause':
console.log('music-controls-pause')
// Do something
break;
case 'music-controls-play':
console.log('music-controls-play')
// Do something
break;
case 'music-controls-destroy':
console.log('music-controls-destroy')
// Do something
break;
};
// this.musicControls.subscribe(events);
this.musicControls.listen();
this.musicControls.updateIsPlaying(true);
});
Scombr0 commented
Move the listen() and the updateIsPlaying() methods out of the callback promise.
this.musicControls.destroy();
console.log("showMp3Player");
this.musicControls.create({
track: this._SurahNameArabic,
artist: this._SurahName,
// cover : 'albums/absolution.jpg',
isPlaying: true,
dismissable: true,
hasPrev: true,
hasNext: true,
hasClose: true,
});
this.musicControls.subscribe().subscribe((action) => {
const message = JSON.parse(action).message;
console.log('action', action);
console.log(message);
console.log("testing event");
switch (message) {
case 'music-controls-next':
console.log('music-controls-next')
// Do something
break;
case 'music-controls-previous':
console.log('music-controls-previous')
// Do something
break;
case 'music-controls-pause':
console.log('music-controls-pause')
// Do something
break;
case 'music-controls-play':
console.log('music-controls-play')
// Do something
break;
case 'music-controls-destroy':
console.log('music-controls-destroy')
// Do something
break;
};
// this.musicControls.subscribe(events);
});
this.musicControls.listen();
this.musicControls.updateIsPlaying(true);