Spaces:
Running
Running
File size: 5,118 Bytes
df61c46 8ff382f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fullscreen Crossfade Slideshow with Audio</title>
<style>
* { margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
#slideshow {
position: relative;
width: 100%;
height: 100%;
cursor: pointer;
background-color: white;
}
.slide {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
transition: opacity 2s ease-in-out;
}
.slide.hidden {
opacity: 0;
z-index: 1;
}
.slide.visible {
opacity: 1;
z-index: 2;
}
.white-background {
background: white;
object-fit: cover;
transform: scaleY(5);
}
</style>
</head>
<body>
<div id="slideshow">
<img id="slide1" class="slide visible" src="https://huggingface.co/datasets/vericudebuget/test1423/resolve/main/WhatsApp%20Image%202025-05-16%20at%203.03.14%20PM.jpeg" alt="">
<img id="slide2" class="slide hidden" src="" alt="">
</div>
<audio id="bgAudio" preload="auto" style="display:none;">
<source src="https://huggingface.co/datasets/vericudebuget/test1423/resolve/main/ytmp3free.cc_corul-buna-vestire-francisc-hubic-miluiestema-dumnezeule-gheorghe-cucu-youtubemp3free.o%20(1).mp3?download=true" type="audio/mpeg">
</audio>
<script>
const images = [
'https://huggingface.co/datasets/vericudebuget/test1423/resolve/main/WhatsApp%20Image%202025-05-16%20at%203.03.14%20PM.jpeg',
'https://huggingface.co/datasets/vericudebuget/test1423/resolve/main/WhatsApp%20Image%202025-05-16%20at%203.03.14%20PM%20(1).jpeg',
'https://huggingface.co/datasets/vericudebuget/test1423/resolve/main/WhatsApp%20Image%202025-05-16%20at%203.03.14%20PM%20(2).jpeg'
];
images.forEach(url => new Image().src = url);
const slide1 = document.getElementById('slide1');
const slide2 = document.getElementById('slide2');
const slideshow = document.getElementById('slideshow');
const bgAudio = document.getElementById('bgAudio');
bgAudio.volume = 0;
const slides = [
{ type: 'image', src: images[0] },
{ type: 'image', src: images[1] },
{ type: 'audio' },
{ type: 'image', src: images[2] },
{ type: 'white' }
];
let currentIndex = 0;
let isAudioPlaying = false;
slideshow.addEventListener('click', () => {
const nextIndex = (currentIndex + 1);
const nextSlide = slides[nextIndex];
if (!nextSlide) return;
if (nextSlide.type === 'audio') {
bgAudio.currentTime = 0;
bgAudio.play();
isAudioPlaying = true;
fadeVolume(bgAudio, 0, 1, 3000);
} else if (nextSlide.type === 'image') {
const topSlide = slide1.classList.contains('visible') ? slide1 : slide2;
const bottomSlide = topSlide === slide1 ? slide2 : slide1;
const prevIdx = slides.findIndex(s => s.src === topSlide.src);
const newIdx = images.indexOf(nextSlide.src);
const duration = (prevIdx === 1 && newIdx === 2) ? 5 : 2;
slide1.style.transition = `opacity ${duration}s ease-in-out`;
slide2.style.transition = `opacity ${duration}s ease-in-out`;
bottomSlide.src = nextSlide.src;
bottomSlide.alt = "";
bottomSlide.classList.remove('white-background');
bottomSlide.classList.remove('hidden');
bottomSlide.classList.add('visible');
topSlide.classList.remove('visible');
topSlide.classList.add('hidden');
} else if (nextSlide.type === 'white') {
fadeVolume(bgAudio, bgAudio.volume, 0, 10000);
const topSlide = slide1.classList.contains('visible') ? slide1 : slide2;
const bottomSlide = topSlide === slide1 ? slide2 : slide1;
bottomSlide.removeAttribute('src');
bottomSlide.alt = "";
bottomSlide.classList.add('white-background');
bottomSlide.style.transition = 'opacity 10s ease-in-out';
topSlide.style.transition = 'opacity 10s ease-in-out';
bottomSlide.classList.remove('hidden');
bottomSlide.classList.add('visible');
topSlide.classList.remove('visible');
topSlide.classList.add('hidden');
}
currentIndex = nextIndex;
});
function fadeVolume(audio, from, to, duration) {
const steps = 30;
const stepTime = duration / steps;
let step = 0;
const volumeStep = (to - from) / steps;
const fade = setInterval(() => {
audio.volume = Math.min(Math.max(audio.volume + volumeStep, 0), 1);
if (++step >= steps) clearInterval(fade);
if (audio.volume === 0) audio.pause();
}, stepTime);
}
document.addEventListener('keydown', (e) => {
if (e.key.toLowerCase() === 'k') {
if (bgAudio.paused) {
bgAudio.play();
isAudioPlaying = true;
} else {
bgAudio.pause();
isAudioPlaying = false;
}
}
});
</script>
</body>
</html>
|