-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: neev jewalkar <neevjewalkar@neevs-MacBook-Pro.local> Co-authored-by: Restyled.io <commits@restyled.io>
- Loading branch information
1 parent
cad584d
commit f2bcb2c
Showing
24 changed files
with
146 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,67 @@ | ||
var songs = [ | ||
"/music/christmas/AVeryMogulChristmas.mp3", | ||
"/music/christmas/FelizNavidad.mp3", | ||
"/music/christmas/DeckTheHalls.mp3", | ||
"/music/christmas/It'sThatTimeOfTheYear.mp3", | ||
]; | ||
|
||
var audioElement = document.getElementById('my_audio'); | ||
var musicOnButton = document.getElementById('musicOnButton'); | ||
|
||
function playMusic() { | ||
var randomIndex = Math.floor(Math.random() * songs.length); | ||
var audioSource = document.getElementById('audio_source'); | ||
audioSource.src = songs[randomIndex]; | ||
audioElement.load(); | ||
|
||
audioElement.addEventListener('canplaythrough', function() { | ||
audioElement.play().catch(function(error) { | ||
console.log('Error playing audio:', error); | ||
// Song URL | ||
const songs = [ | ||
"/music/christmas/AVeryMogulChristmas.mp3", | ||
"/music/christmas/FelizNavidad.mp3", | ||
"/music/christmas/DeckTheHalls.mp3", | ||
"/music/christmas/It'sThatTimeOfTheYear.mp3", | ||
]; | ||
|
||
// Initialize DOM variables | ||
let audioElement = document.getElementById("my_audio"); | ||
let musicOnButton = document.getElementById("musicOnButton"); | ||
let musicOffButton = document.getElementById("musicOffButton"); | ||
|
||
// Define the playMusic function, handling the music | ||
const playMusic = () => { | ||
// Define the song and its URL | ||
let randomIndex = Math.floor(Math.random() * songs.length); | ||
let audioSource = document.getElementById("audio_source"); | ||
|
||
// Load the song info into the audioElement | ||
audioSource.src = songs[randomIndex]; | ||
audioElement.load(); | ||
|
||
// Update the AudioElement to handle playing the song | ||
audioElement.addEventListener( | ||
"canplaythrough", | ||
() => { | ||
try { | ||
audioElement.play(); | ||
musicOnButton.style.display = "none"; | ||
musicOffButton.style.display = "block"; | ||
} catch (err) { | ||
pauseMusic(); | ||
}); | ||
musicOnButton.style.display = 'none'; | ||
}, { once: true }); | ||
throw err; | ||
} | ||
}, | ||
{ once: true } | ||
); | ||
|
||
audioElement.addEventListener('pause', function() { | ||
musicOnButton.style.display = 'block'; | ||
}); | ||
} | ||
// Update the AudioElement to handle pausing the song | ||
audioElement.addEventListener("pause", function () { | ||
musicOnButton.style.display = "block"; | ||
musicOffButton.style.display = "none"; | ||
}); | ||
}; | ||
|
||
function pauseMusic() { | ||
audioElement.pause(); | ||
musicOnButton.style.display = 'block'; | ||
} | ||
// Define the pauseMusic function, handling the commands to stop the music | ||
const pauseMusic = () => { | ||
audioElement.pause(); | ||
musicOnButton.style.display = "block"; | ||
musicOffButton.style.display = "none"; | ||
}; | ||
|
||
function toggleMusic() { | ||
if (audioElement.paused) { | ||
playMusic(); | ||
} else { | ||
pauseMusic(); | ||
} | ||
// Define the toggleMusic function, handling the commands to toggle | ||
// the buttons "musicOnButton" and "musicOffButton" | ||
const toggleMusic = () => { | ||
if (audioElement.paused) { | ||
playMusic(); | ||
} else { | ||
pauseMusic(); | ||
} | ||
}; | ||
|
||
// Play music on page load | ||
window.addEventListener('load', function() { | ||
playMusic(); | ||
}); | ||
// Play music on page load | ||
window.addEventListener("load", () => { | ||
playMusic(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
document.querySelector(".go-back").addEventListener("click", () => { | ||
window.history.back(); | ||
}); | ||
|
||
window.history.back(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,61 @@ | ||
var songs = [ | ||
"/music/apc.mp3", | ||
"/music/beachvibes.mp3", | ||
"/music/bliss.mp3", | ||
"/music/Fluffing-a-Duck.mp3", | ||
"/music/happyafricanvillage.mp3", | ||
"/music/happyandjoyfulchildren.mp3", | ||
"/music/newlands.mp3", | ||
"/music/sotb.mp3", | ||
"/music/tropicalfever.mp3", | ||
"/music/tropicalsoul.mp3", | ||
"/music/ukulele.mp3", | ||
]; | ||
const songs = [ | ||
"/music/apc.mp3", | ||
"/music/beachvibes.mp3", | ||
"/music/bliss.mp3", | ||
"/music/Fluffing-a-Duck.mp3", | ||
"/music/happyafricanvillage.mp3", | ||
"/music/happyandjoyfulchildren.mp3", | ||
"/music/newlands.mp3", | ||
"/music/sotb.mp3", | ||
"/music/tropicalfever.mp3", | ||
"/music/tropicalsoul.mp3", | ||
"/music/ukulele.mp3", | ||
]; | ||
|
||
var audioElement = document.getElementById('my_audio'); | ||
var musicOnButton = document.getElementById('musicOnButton'); | ||
let audioElement = document.getElementById("my_audio"); | ||
let musicOnButton = document.getElementById("musicOnButton"); | ||
let musicOffButton = document.getElementById("musicOffButton"); | ||
|
||
function playMusic() { | ||
var randomIndex = Math.floor(Math.random() * songs.length); | ||
var audioSource = document.getElementById('audio_source'); | ||
audioSource.src = songs[randomIndex]; | ||
audioElement.load(); | ||
const playMusic = () => { | ||
var randomIndex = Math.floor(Math.random() * songs.length); | ||
var audioSource = document.getElementById("audio_source"); | ||
audioSource.src = songs[randomIndex]; | ||
audioElement.load(); | ||
|
||
audioElement.addEventListener('canplaythrough', function() { | ||
audioElement.play().catch(function(error) { | ||
console.log('Error playing audio:', error); | ||
audioElement.addEventListener( | ||
"canplaythrough", | ||
() => { | ||
audioElement.play().catch((error) => { | ||
console.log("Error playing audio:", error); | ||
pauseMusic(); | ||
}); | ||
musicOnButton.style.display = 'none'; | ||
}, { once: true }); | ||
musicOnButton.style.display = "none"; | ||
musicOffButton.style.display = "block"; | ||
}, | ||
{ once: true } | ||
); | ||
|
||
audioElement.addEventListener('pause', function() { | ||
musicOnButton.style.display = 'block'; | ||
}); | ||
} | ||
audioElement.addEventListener("pause", () => { | ||
musicOnButton.style.display = "block"; | ||
musicOffButton.style.display = "none"; | ||
}); | ||
}; | ||
|
||
function pauseMusic() { | ||
audioElement.pause(); | ||
musicOnButton.style.display = 'block'; | ||
} | ||
const pauseMusic = () => { | ||
audioElement.pause(); | ||
musicOnButton.style.display = "block"; | ||
musicOffButton.style.display = "none"; | ||
}; | ||
|
||
function toggleMusic() { | ||
if (audioElement.paused) { | ||
playMusic(); | ||
} else { | ||
pauseMusic(); | ||
} | ||
const toggleMusic = () => { | ||
if (audioElement.paused) { | ||
playMusic(); | ||
} else { | ||
pauseMusic(); | ||
} | ||
}; | ||
|
||
// Play music on page load | ||
window.addEventListener('load', function() { | ||
playMusic(); | ||
}); | ||
// Play music on page load | ||
window.addEventListener("load", () => { | ||
playMusic(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.