Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Play Audio from URL</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| background: #0d1117; | |
| color: #e6edf3; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| height: 100vh; | |
| } | |
| input { | |
| width: 80%; | |
| max-width: 500px; | |
| padding: 10px; | |
| margin-bottom: 20px; | |
| border-radius: 8px; | |
| border: none; | |
| outline: none; | |
| font-size: 16px; | |
| } | |
| button { | |
| padding: 10px 20px; | |
| font-size: 16px; | |
| background-color: #238636; | |
| border: none; | |
| border-radius: 8px; | |
| color: white; | |
| cursor: pointer; | |
| transition: background 0.2s; | |
| } | |
| button:hover { | |
| background-color: #2ea043; | |
| } | |
| audio { | |
| margin-top: 30px; | |
| width: 80%; | |
| max-width: 500px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h2>🎵 Play Audio from URL</h2> | |
| <input type="text" id="audioUrl" placeholder="Enter audio URL (e.g. https://example.com/song.mp3)" /> | |
| <button onclick="playAudio()">Play</button> | |
| <audio id="audioPlayer" controls></audio> | |
| <script> | |
| function playAudio() { | |
| const url = document.getElementById("audioUrl").value.trim(); | |
| const player = document.getElementById("audioPlayer"); | |
| if (!url) { | |
| alert("Please enter a valid audio URL!"); | |
| return; | |
| } | |
| player.src = url; | |
| player.play().catch(err => { | |
| alert("Error playing audio. Check the URL or CORS restrictions."); | |
| console.error(err); | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> | |