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 dbc5a13 commit d5f7c43
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 55 deletions.
111 changes: 81 additions & 30 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.

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

// MOBILE CHECK
window.mobileCheck = function () {
let check = false;
Expand Down Expand Up @@ -141,7 +144,6 @@ export default function audioImplementation() {

// MUTE FUNCTIONALITY
const mute_btn = document.querySelector("#mute-btn-container");
const showreelVideo = document.querySelector("#showreel_home");

const soundwave = document.querySelector(".soundwave-svg");
const wave = document.querySelectorAll(".wave");
Expand All @@ -161,19 +163,32 @@ export default function audioImplementation() {
autoplay: true,
});

let showreelMuteState = false;

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

if (!isMuted) {
if (mobileCheck() == false) {
music.volume = music_volume;
music.muted = 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 muted during video playback");
showreelMuteState = true;
}
music.volume = 0;
mute_lottie.setSpeed(1.5);
mute_lottie.loop = false;
Expand All @@ -182,6 +197,7 @@ export default function audioImplementation() {
music.play();
}
// }
console.log(showreelMuteState);
});

// catch to make sure music & mute-lottie is never out of sync
Expand Down Expand Up @@ -416,9 +432,14 @@ export default function audioImplementation() {
function fadeInMusic() {
// $(window).on("load", function () {
music.play();
if (!isMuted) {
music.volume = 0;
$(music).animate({ volume: music_volume }, 1500, "linear");
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");
}
}
// });
}
Expand All @@ -429,23 +450,32 @@ export default function audioImplementation() {
maxVolume = music_volume,
isFromShowreel = true
) {
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;
});
console.log("ran")
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;
});
}
}

// func to toggle mute state
function muteToggle() {
if (isMuted) {
unmuteAll(uiSounds);
isMuted = false;
showreelMuteState = false;
} else {
muteAll(uiSounds);
isMuted = true;
showreelMuteState = true;
}
}

Expand All @@ -468,6 +498,10 @@ export default function audioImplementation() {
return isMuted;
}

function getShowreelMuteState() {
return showreelMuteState;
}

// forcefully set mute state
function setMuteState(state) {
isMuted = state;
Expand Down Expand Up @@ -503,5 +537,6 @@ export default function audioImplementation() {
mutedState,
toggleCssAnim,
setMuteState,
getShowreelMuteState,
};
}
Loading

0 comments on commit d5f7c43

Please sign in to comment.