-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (52 loc) · 2.21 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Happy Birthday</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="drag-container">
<div id="spin-container">
<!-- Add your image or video here -->
<img src="images/1.jpg" alt="" class="playAudioButton">
<img src="images/2.jpg" alt="" class="playAudioButton">
<img src="images/3.jpg" alt="" class="playAudioButton">
<img src="images/4.jpg" alt="" class="playAudioButton">
<img src="images/5.jpg" alt="" class="playAudioButton">
<img src="images/6.jpg" alt="" class="playAudioButton">
<img src="images/7.jpg" alt="" class="playAudioButton">
<img src="images/8.jpg" alt="" class="playAudioButton">
<!-- <video controls autoplay="autoplay" loop>
<source src="" type="video/mp4">
</video> -->
<!-- Text at Center of the ground -->
<p>Happy Birthday Sweetu💞🎂</p>
</div>
<div id="ground"></div>
</div>
<!-- Add audio element -->
<audio id="birthdayAudio" src="aud.mp3" preload="auto"></audio>
<!-- Add a button to play the audio -->
<!-- <button id="playAudioButton" style="display: none;">Play Audio</button> -->
<script src="script.js"></script>
<script>
// Function to play the audio
const playAudio = () => {
const audio = document.getElementById('birthdayAudio');
audio.play().catch(() => {
// Show the play button if autoplay fails
// document.getElementById('playAudioButton').style.display = 'block';
});
};
// Try to play audio when the page loads
window.addEventListener('load', playAudio);
// Play audio when any image with the class 'playAudioButton' is clicked
const images = document.querySelectorAll('.playAudioButton');
images.forEach(image => {
image.addEventListener('click', playAudio);
});
</script>
</body>
</html>