Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
startPlaying(props) {
if (props.isPlaying && props.currentSong) {
// If it should be playing any song
const url = props.currentSong.get("url");
const format = url.split(".").pop();
const isPlayable = Howler.codecs(format);
if (isPlayable) {
// Build a new Howler object with current song to play
this.howl = new Howl({
src: [url],
html5: true, // Use HTML5 by default to allow streaming
mute: props.isMute,
volume: props.volume / 100, // Set current volume
autoplay: false, // No autoplay, we handle it manually
format: format, // Specify format as Howler is unable to fetch it from URL
onloaderror: () => props.actions.setError(ONLOAD_ERROR), // Display error if song cannot be loaded
onend: () => props.actions.playNextSong(), // Play next song at the end
});
// Start playing
this.howl.play();
} else {
// Howler already performs this check on his own, but we have