Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_setNowPlaying(track: Track): void {
let config = { ...this.setNowPlayingConfig };
let info = this._getInfo(track.additionalInfo);
MusicControl.setNowPlaying({
...info,
color: config.color, // Notification Color - Android Only
notificationIcon: config.notificationIcon // Android Only (String), Android Drawable resource name for a custom notification icon
});
}
test('MusicPlayerService | _setNowPlaying with track with no additionalInfo | setNowPlaying is set with default values', () => {
let setNowPlayingConfig = {
color: 'some color',
notificationIcon: 'notificationIcon'
}
let musicPlayerService = new MusicPlayerService(true, setNowPlayingConfig);
let trackWithNoAdditionalInfo = new Track({ id: '1', path: 'some path' });
expect.assertions(2);
musicPlayerService._setNowPlaying(trackWithNoAdditionalInfo);
expect(MusicControl.setNowPlaying).toHaveBeenCalledTimes(1);
expect(MusicControl.setNowPlaying).toHaveBeenCalledWith({
title: '',
artwork: undefined,
artist: '',
album: '',
genre: '',
duration: 0,
color: setNowPlayingConfig.color,
notificationIcon: setNowPlayingConfig.notificationIcon
});
});
beforeEach(() => {
Sound.mockReset();
Sound.prototype.play.mockClear();
Sound.prototype.pause.mockClear();
Sound.prototype.stop.mockClear();
Sound.prototype.release.mockClear();
MusicControl.on.mockClear();
MusicControl.enableControl.mockClear();
MusicControl.enableBackgroundMode.mockClear();
MusicControl.setNowPlaying.mockClear();
MusicControl.updatePlayback.mockClear();
});
setPlayingSong(duration) {
let song = this.props.songs[this.props.songIndex];
MusicControl.setNowPlaying({
title: song.title,
artwork: song.thumb,
artist: song.artist,
duration
});
}
() => {
MusicControl.enableControl("seekForward", false);
MusicControl.enableControl("seekBackward", false);
MusicControl.enableControl("skipForward", false);
MusicControl.enableControl("skipBackward", false);
MusicControl.enableBackgroundMode(true);
const { streamChapter } = this.state;
MusicControl.setNowPlaying({
title: `${streamChapter && streamChapter.activeBook.name_id} ${streamChapter && streamChapter.activeChapter}`,
artist: "Alkitab Suara",
duration: this.state.streamDuration,
color: 0xfffffff
});
MusicControl.on("play", () => {
this.setState({ paused: false });
});
MusicControl.on("pause", () => {
this.setState({ paused: true });
});
MusicControl.on("nextTrack", () => {});
MusicControl.on("previousTrack", () => {});
MusicControl.updatePlayback({