sumitkolhe / jiosaavn-api

🎵 An Unofficial API for downloading high-quality songs from JioSaavn
https://saavn.dev
MIT License
256 stars 116 forks source link

`captureStream()` from audio Element using Web Audio API : Shows Error #22

Closed harshalkaigaonkar closed 1 year ago

harshalkaigaonkar commented 1 year ago

Hey Sumit,

Not an Issue, but want some Help regarding this.

Great Project, I had an idea to built on same wherin we can stream music in realtime on top of this. (Like this, but audio-audio) But, there's been an issue bugging me with a process, whenever from an audio tag song is played and try to capture stream for the same. Getting this error : DOMException: Failed to execute 'captureStream' on 'HTMLMediaElement': Cannot capture from element with cross-origin data Is there any way, which supress the CORS error while capturing Stream from Audio Tag? can also directly, stream from a new server, but want to make it from client side.

Can you help me figure out?

sumitkolhe commented 1 year ago

hey @harshalkaigaonkar , did you try setting crossOrigin="anonymous" in the audio tag? can you provide any code you've been using, since its hard to debug like this.

harshalkaigaonkar commented 1 year ago

Yeah sure. https://gist.github.com/harshalkaigaonkar/172e39c0b79205e5be134111524454d3. Have used crossorigin in the media tag. as the track link redirects to another one, which does not have cors handled on audio side Ig. is there anything i'm missing?

harshalkaigaonkar commented 1 year ago

Yeah sure. https://gist.github.com/harshalkaigaonkar/172e39c0b79205e5be134111524454d3. Have used crossorigin in the media tag. as the track link redirects to another one, which does not have cors handled on audio side Ig. is there anything i'm missing?

Hey Sumit, have you checked this?

sumitkolhe commented 1 year ago

@harshalkaigaonkar i checked it, looks like cdnsrv.jio.com has CORS enabled, so even though the apis work fine, the song cannot be streamed directly like the way you're trying to do using just the client side.

harshalkaigaonkar commented 1 year ago

Okay, Thanks. I'll try to use that from Server using buffers or try with setting up a cdn via storage like s3.