Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshvdw committed Nov 16, 2023
1 parent d5f7c43 commit 209e773
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 64 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const homePage = currentPage == "/";
const onReady = () => {
readyPreloader(); // hides preloader and add event listener for frog lottie
const page = window.location.pathname.split("/").pop();
const audio = audioImplementation(); // adds music, ui-sounds and mute-lottie functionality
const audio = audioImplementation(homePage); // adds music, ui-sounds and mute-lottie functionality
if (homePage) showreelHome(audio); // code for homepage showreel video
showreelNav(audio); // code for nav showreel video
logCareers(); // logs a frog and message to the console
Expand Down
91 changes: 69 additions & 22 deletions dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/app.js.map

Large diffs are not rendered by default.

130 changes: 90 additions & 40 deletions js/global/audio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function audioImplementation() {
export default function audioImplementation(homePage) {
const showreelHome = document.querySelector("#showreel_home");
const showreelNav = document.querySelector("#showreel_nav");

Expand Down Expand Up @@ -167,37 +167,59 @@ export default function audioImplementation() {

// MUTE BUTTON TOGGLE ON CLICK
mute_btn.addEventListener("click", function () {
// if (showreelVideo == null || showreelVideo.muted || showreelVideo.paused) {
muteToggle();

if (!isMuted) {
if (mobileCheck() == false) {
if (showreelHome) {
if (!isMuted) {
if (mobileCheck() == false) {
if (!showreelHome.muted || !showreelNav.muted) {
console.log("user unmuted during video playback");
showreelMuteState = false;
} else {
console.log("custom mute func ran");
music.volume = music_volume;
music.muted = false;
}
}
mute_lottie.setSpeed(1);
mute_lottie.loop = true;
mute_lottie.play();
} else {
if (!showreelHome.muted || !showreelNav.muted) {
console.log("user unmuted during video playback");
showreelMuteState = false;
} else {
console.log("custom mute func ran");
music.volume = music_volume;
music.muted = false;
console.log("user muted during video playback");
showreelMuteState = true;
}
music.volume = 0;
mute_lottie.setSpeed(1.5);
mute_lottie.loop = false;
}
mute_lottie.setSpeed(1);
mute_lottie.loop = true;
mute_lottie.play();
} else {
if (!showreelHome.muted || !showreelNav.muted) {
console.log("user muted during video playback");
showreelMuteState = true;
if (!isMuted) {
if (mobileCheck() == false) {
if (!showreelNav.muted) {
console.log("user unmuted during video playback");
showreelMuteState = false;
} else {
console.log("custom mute func ran");
music.volume = music_volume;
music.muted = false;
}
}
mute_lottie.setSpeed(1);
mute_lottie.loop = true;
mute_lottie.play();
} else {
if (!showreelNav.muted) {
console.log("user muted during video playback");
showreelMuteState = true;
}
music.volume = 0;
mute_lottie.setSpeed(1.5);
mute_lottie.loop = false;
}
music.volume = 0;
mute_lottie.setSpeed(1.5);
mute_lottie.loop = false;
}
if (muteState) {
music.play();
}
// }
console.log(showreelMuteState);
});

// catch to make sure music & mute-lottie is never out of sync
Expand Down Expand Up @@ -432,13 +454,25 @@ export default function audioImplementation() {
function fadeInMusic() {
// $(window).on("load", function () {
music.play();
if (!showreelHome.muted || !showreelNav.muted) {
console.log("fade in triggered, but didn't run");
if (showreelHome) {
if (!showreelHome.muted || !showreelNav.muted) {
console.log("fade in triggered, but didn't run");
} else {
if (!isMuted) {
console.log("fade in triggered & ran");
music.volume = 0;
$(music).animate({ volume: music_volume }, 1500, "linear");
}
}
} else {
if (!isMuted) {
console.log("fade in triggered & ran");
music.volume = 0;
$(music).animate({ volume: music_volume }, 1500, "linear");
if (!showreelNav.muted) {
console.log("fade in triggered, but didn't run");
} else {
if (!isMuted) {
console.log("fade in triggered & ran");
music.volume = 0;
$(music).animate({ volume: music_volume }, 1500, "linear");
}
}
}
// });
Expand All @@ -450,19 +484,35 @@ export default function audioImplementation() {
maxVolume = music_volume,
isFromShowreel = true
) {
console.log("ran")
if ((!showreelHome.muted || !showreelNav.muted) && !isFromShowreel) {
console.log("fade toggle triggered, but didn't run");
console.log("ran");
if (homePage) {
if ((!showreelHome.muted || !showreelNav.muted) && !isFromShowreel) {
console.log("fade toggle triggered, but didn't run");
} else {
console.log("fade toggle triggered & ran");
// console.log(mutedState());
let muted = audio.muted;
if (muted && !isFromShowreel) audio.muted = false;
let newVolume = muted ? maxVolume : 0;
if (!isFromShowreel) newVolume = maxVolume;
$(audio).animate({ volume: muted ? maxVolume : 0 }, 1000, function () {
audio.muted = !muted;
});
}
} else {
console.log("fade toggle triggered & ran");
// console.log(mutedState());
let muted = audio.muted;
if (muted && !isFromShowreel) audio.muted = false;
let newVolume = muted ? maxVolume : 0;
if (!isFromShowreel) newVolume = maxVolume;
$(audio).animate({ volume: muted ? maxVolume : 0 }, 1000, function () {
audio.muted = !muted;
});
if (!showreelNav.muted && !isFromShowreel) {
console.log("fade toggle triggered, but didn't run");
} else {
console.log("fade toggle triggered & ran");
// console.log(mutedState());
let muted = audio.muted;
if (muted && !isFromShowreel) audio.muted = false;
let newVolume = muted ? maxVolume : 0;
if (!isFromShowreel) newVolume = maxVolume;
$(audio).animate({ volume: muted ? maxVolume : 0 }, 1000, function () {
audio.muted = !muted;
});
}
}
}

Expand Down

0 comments on commit 209e773

Please sign in to comment.