Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
expect(MusicControl.updatePlayback).not.toHaveBeenCalled();
});
});
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();
});
() => {
if (this.state.paused) {
MusicControl.updatePlayback({
state: MusicControl.STATE_PAUSED
});
} else {
MusicControl.updatePlayback({
state: MusicControl.STATE_PLAYING
});
}
}
);
goBackward(){
if(this.state.currentTime < 3 && this.props.songIndex !== 0 ) {
this.props.setPlayingSong(this.props.songIndex - 1);
} else {
this.refs.audio.seek(0);
MusicControl.updatePlayback({
state: MusicControl.STATE_PLAYING,
elapsedTime: 0
})
}
}
return this.toggleShuffle(true, true);
}
if(this.props.songs.length == 1) return;
if(this.props.songIndex + 1 != this.props.songs.length) {
let index = this.props.songIndex + 1;
let song = this.props.songs[index];
let changePath = (!song.downloaded && !song.pathChanged);
return this.props.setPlayingSong(index, changePath? this.props.songs: null, changePath);
}
let song = this.props.songs[0];
let changePath = (!song.downloaded && !song.pathChanged);
this.props.setPlayingSong(0, changePath? this.props.songs: null, changePath);
this.props.setPlaying(false);
MusicControl.updatePlayback({
title: song.title,
artwork: song.thumb,
artist: song.artist,
state: MusicControl.STATE_PAUSED,
elapsedTime: 0
});
}
togglePlay(status) {
this.props.setPlaying(status);
MusicControl.updatePlayback({
state: status? MusicControl.STATE_PLAYING: MusicControl.STATE_PAUSED,
elapsedTime: this.state.currentTime
})
}