| 1 | + | <!DOCTYPE html> |
| 2 | + | <html lang="en"> |
| 3 | + | <head> |
| 4 | + | <meta charset="UTF-8"> |
| 5 | + | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + | <title>idi nahui</title> |
| 7 | + | <style> |
| 8 | + | body { |
| 9 | + | font-family: Arial, sans-serif; |
| 10 | + | text-align: center; |
| 11 | + | padding-top: 50px; |
| 12 | + | background-color: #222222; |
| 13 | + | color: rgb(255, 255, 255); |
| 14 | + | } |
| 15 | + | button { |
| 16 | + | padding: 10px 20px; |
| 17 | + | font-size: 16px; |
| 18 | + | cursor: pointer; |
| 19 | + | background-color: #9b0000; |
| 20 | + | color: rgb(255, 255, 255); |
| 21 | + | border: none; |
| 22 | + | border-radius: 5px; |
| 23 | + | } |
| 24 | + | button:hover { |
| 25 | + | background-color: #b13e3e; |
| 26 | + | } |
| 27 | + | </style> |
| 28 | + | </head> |
| 29 | + | <body> |
| 30 | + | |
| 31 | + | <h1>idi nahui</h1> |
| 32 | + | <button id="playButton">idi nahui</button> |
| 33 | + | |
| 34 | + | <script> |
| 35 | + | const mp3Files = [] |
| 36 | + | |
| 37 | + | for (let i = 1; i <= 16; i++) { |
| 38 | + | mp3Files.push(`sounds/${i}.mp3`); |
| 39 | + | } |
| 40 | + | |
| 41 | + | const playButton = document.getElementById('playButton'); |
| 42 | + | let lastPlayedIndex = -1; |
| 43 | + | |
| 44 | + | function playRandomMP3() { |
| 45 | + | let randomIndex; |
| 46 | + | do { |
| 47 | + | randomIndex = Math.floor(Math.random() * mp3Files.length); |
| 48 | + | } while (randomIndex === lastPlayedIndex); |
| 49 | + | |
| 50 | + | lastPlayedIndex = randomIndex; |
| 51 | + | const selectedFile = mp3Files[randomIndex]; |
| 52 | + | |
| 53 | + | const audioPlayer = new Audio(selectedFile); |
| 54 | + | audioPlayer.play(); |
| 55 | + | } |
| 56 | + | |
| 57 | + | playButton.addEventListener('click', playRandomMP3); |
| 58 | + | </script> |
| 59 | + | |
| 60 | + | </body> |
| 61 | + | </html> |
| 62 | + | |