Internet streaming

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
skyHights
Citizen
Posts: 78
Joined: Mon Aug 25, 2014 12:14 pm

Internet streaming

Post by skyHights »

is it possible to get internet sound broadcasts (internet radio) with love or lua and play it through it?
Learning to Löve.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Internet streaming

Post by zorg »

Possible, yes.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
skyHights
Citizen
Posts: 78
Joined: Mon Aug 25, 2014 12:14 pm

Re: Internet streaming

Post by skyHights »

zorg wrote:Possible, yes.
How would one go about doing it do you know?
Learning to Löve.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Internet streaming

Post by zorg »

Yes, i know how one would go about doing it. :3

...seriously now, it's really not that simple a thing to do.
In broad strokes, you'd need to get or write a lib capable of handling whatever net protocol the stream you'd want to listen to would use, it itself continuously receiving more data into a buffer, which you'd need to queue up for your soundcard to play back.
No idea whether any lua lib exists or not for the first part, the second can be solved with lpghatguy's queuablesource.lua, itself part of a lib allowing audio recording.
Furthermore, if you do intend all this to work alongside an actual game, for instance, all this should be threaded as well... how well that would work with data streams and buffer accessing is a can of worms even i don't really want to open after nearly 3 years now (of using löve) .
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
skyHights
Citizen
Posts: 78
Joined: Mon Aug 25, 2014 12:14 pm

Re: Internet streaming

Post by skyHights »

Right...
So that isn't going to be happening...
Learning to Löve.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: Internet streaming

Post by alloyed »

Internet radio isn't that complex, actually: usually it's just an endless http file that happens to contain mp3/ogg/whatever data.
So you need, ultimately, 2 things:
1. A way to open a request and keep it open
2. A way to turn that data into a love.audio source

The easiest way I see, since love.audio already supports file-backed streaming sources, is to open a request on a new thread that pushes to a temp file (or ideally a named pipe), and then just read from that file on the main thread.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Internet streaming

Post by zorg »

Not to nitpick, but one would think that streams used RT(S)P at least, and not http; you'd get the "playlist file" through http, that's possible, but whatever's inside it, usually one line, and not audio data, is the address from where the stream sends out the data proper.

And despite löve can stream audio from disk doesn't mean you can concurrently write to (whether append or replace the content in the process) the file that's currently streaming.

Then again, I might be wrong, but these were my usual experiences.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

Re: Internet streaming

Post by Pangit »

Could you not approach the problem in a different way - while its operating system dependant and you would need to verify that the software was on the machine in the first play using the system commands you could load the program, run the stream whilst running your lua program. Depending on what program you had - odds are especially for linux a lot of them can run in headless mode. Not sure about windows or mac.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: Internet streaming

Post by alloyed »

zorg wrote:Not to nitpick, but one would think that streams used RT(S)P at least, and not http; you'd get the "playlist file" through http, that's possible, but whatever's inside it, usually one line, and not audio data, is the address from where the stream sends out the data proper.

And despite löve can stream audio from disk doesn't mean you can concurrently write to (whether append or replace the content in the process) the file that's currently streaming.

Then again, I might be wrong, but these were my usual experiences.
At least last time I messed with icecast, http was the default.

I found an example: this is my local public radio, which provides a flash-based player and a .pls file which links to this.

Code: Select all

curl http://wamu-1.streamguys.com | mpg123 -
The point about concurrent read/write is a problem though. I'm kind of itching to try to make a streaming library myself just to see how it works out now :>
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 50 guests