<div dir="ltr"><div>Thanks a million for the replies, guys.</div><div><br></div>@Daniel:<div>1. That's what I thought. I could try this for personal use but it's clearly not the most scalable option.</div><div><br></div><div>2. So using ports I'd be spawning a worker that streams the audio back to the erlang process, per user that's online and listening. I'll give this a shot with pyspotify. Let's hope they allow for multiple audio streams for different sessions from the same host!</div><div><br></div><div>3. Unfortunately the Spotify Web API doesn't provide full playback (only 30s previews), but for the rest of the data I was going to use that.<br></div><div><br></div><div>@Jesper: Indeed the library is not thread-safe. Thanks for clearing up what that meant. And it seems that they haven't updated libspotify in the past 2 years, so hopefully with the releasing of the new Web API they'll roll out a new release of the C lib.</div><div><br></div><div>Thanks for your time guys, I'll be giving this a shot and get back.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 13, 2015 at 10:43 AM, Jesper Louis Andersen <span dir="ltr"><<a href="mailto:jesper.louis.andersen@gmail.com" target="_blank">jesper.louis.andersen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><br><div class="gmail_quote">On Thu, Mar 12, 2015 at 11:45 PM, Leandro Ostera <span dir="ltr"><<a href="mailto:me@leostera.com" target="_blank">me@leostera.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="font-size:13px">I was trying to use a quite old <a href="https://github.com/arjan/espotify" target="_blank">erlang wrapper around libspotify</a>, which seems to be defining a bunch of NIFs, to make an audio streaming server that would keep N web-based clients playing the same audio at (give or take milliseconds) the same time. The problem is that according to <a href="https://github.com/arjan/espotify/blob/master/src/espotify_api.erl#L73-L84" target="_blank">one of the source files</a>, it'd only be able to have one open Spotify session per VM, which of course didn't sound too exciting.</div></blockquote></div><br></span>The library may not be thread-safe. That is, it assumes a single thread for access and it stores session information in global variables inside the library itself. You may want to check if there is a newer version of the library without these limitations.</div><div class="gmail_extra"><br></div><div class="gmail_extra">NIFs do support proper multithreading and local context, but the library needs to support it as well. The term you are looking for w.r.t the context are 'resources':</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="http://www.erlang.org/doc/man/erl_nif.html#enif_resource_example" target="_blank">http://www.erlang.org/doc/man/erl_nif.html#enif_resource_example</a><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div><div><br></div>-- <br><div>J.</div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="font-family:arial">Leandro Ostera</span><div dir="ltr" style="font-family:arial"><div><br></div><div><font size="1"><a href="http://github.com/ostera" style="color:rgb(17,85,204)" target="_blank">Github</a> | <a href="http://linkedin.com/in/leostera" style="color:rgb(17,85,204)" target="_blank">LinkedIn</a> | <a href="http://facebook.com/leostera" style="color:rgb(17,85,204)" target="_blank">Facebook</a> | <a href="http://twitter.com/leostera" style="color:rgb(17,85,204)" target="_blank">@leostera</a></font></div></div></div></div></div></div></div></div>
</div>