jkeen / ember-stereo

The best way to reactively handle audio in your modern ember app
https://ember-stereo.com
MIT License
19 stars 3 forks source link

On Demand URL Example? #20

Closed jagthedrummer closed 1 year ago

jagthedrummer commented 1 year ago

This page seems to show an example of using an on demand url but the code snippet for the example is missing. It would be helpful to see the code, or to have an explanation of how it works.

https://ember-stereo.com/docs/playing-sounds#on-demand-url

jkeen commented 1 year ago

The code is the same as the example above it.

And "on demand" is WNYC radio lingo for just a static file, and maybe that should be changed… Just saying that that example is nothing fancy, it's just using a path to an mp3 file for the identifier value you see in the code sample above it.

jagthedrummer commented 1 year ago

Ah! I was misunderstanding what on-demand meant in this context. I thought that it meant something like "after you click the play button we'll retrieve the actual URL over the network and then start to play it". (In my case the files are in a protected S3 bucket and I need to sign a request in order to be able to download them, and I incorrectly assumed that "on-demand" was for that kind of thing.)

jkeen commented 1 year ago

One thing that might not be very clear either is that you can pass a promise that returns an identifier (a url or an array of urls to try) into stereo to play, and it will resolve as part of the playing process. In your case that promise would return a signed url with a short expiration time, probably.

It was something that was built in a long ago to get past some some browser autoplay restrictions when the URL wasn't known at page load and it should still work! I haven't used that method lately for the projects that I use stereo on, but it sounds like it might be useful in your case.