File size: 1,723 Bytes
b1e3e0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<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>