import { MusicControls } from '@awesome-cordova-plugins/music-controls/ngx';
constructor(private musicControls: MusicControls) { }
...
this.musicControls.create({
track : 'Time is Running Out',
artist : 'Muse',
cover : 'albums/absolution.jpg',
isPlaying : true,
dismissable : true,
hasPrev : false,
hasNext : false,
hasClose : true,
album : 'Absolution',
duration : 60,
elapsed : 10,
hasSkipForward : true,
hasSkipBackward : true,
skipForwardInterval: 15,
skipBackwardInterval: 15,
hasScrubbing: false,
ticker : 'Now playing "Time is Running Out"',
playIcon: 'media_play',
pauseIcon: 'media_pause',
prevIcon: 'media_prev',
nextIcon: 'media_next',
closeIcon: 'media_close',
notificationIcon: 'notification'
});
this.musicControls.subscribe().subscribe(action => {
function events(action) {
const message = JSON.parse(action).message;
switch(message) {
case 'music-controls-next':
break;
case 'music-controls-previous':
break;
case 'music-controls-pause':
break;
case 'music-controls-play':
break;
case 'music-controls-destroy':
break;
case 'music-controls-toggle-play-pause' :
break;
case 'music-controls-seek-to':
const seekToInSeconds = JSON.parse(action).position;
this.musicControls.updateElapsed({
elapsed: seekToInSeconds,
isPlaying: true
});
break;
case 'music-controls-skip-forward':
break;
case 'music-controls-skip-backward':
break;
case 'music-controls-media-button' :
break;
case 'music-controls-headset-unplugged':
break;
case 'music-controls-headset-plugged':
break;
default:
break;
}
}
});
this.musicControls.listen();
this.musicControls.updateIsPlaying(true);