0

I've a link which came from an api call (https://open.spotify.com/embed/track/5H1H2gRlCaB0mj961DCuFT) now i want this link to play as an audio in my html page. I've tried using iFrame but if i use them then I can't track the current time of the audio file. And if i use audio tag then the file isn't playing. So, what should I do to track the time of the iFrame tag or is there any better solution to this?

Rishab Sharma
  • 61
  • 1
  • 7
  • Check this video if this solved your problem I will type the answer https://youtu.be/1Doanzn6alA – nourza Apr 17 '20 at 10:34

2 Answers2

0

https://open.spotify.com/embed/track/5H1H2gRlCaB0mj961DCuFT is an HTML document. It has an embedded audio player.

If you want to play an audio file and be able to monitor things like playback then you need an actual audio file. I very much doubt Spotify would provide access to that (as it would be counter to their business model) so you'd need to find another source for the audio. (Make sure you license it appropriately).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

You can play audio using javascript from URL as below :

function play() {
  var audio = new Audio('https://www2.cs.uic.edu/~i101/SoundFiles/StarWars3.wav');
  audio.play();
}
<button onclick="play()">Play Audio</button>

Refer original SO answer for more details

Ankit Prajapati
  • 2,670
  • 2
  • 12
  • 22