Start online radio in the background?

Started by Gabor, Mon 01/02/2021 18:15:42

Previous topic - Next topic

Gabor

I thought it would be nice to launch an online radio station when the game starts, and it should stop when the game is closed.

I have the AGS Shell Plugin in place, and in GlobalScript.asc in game_start() I added
Code: ags

ShellExecute("", "https://xxxxxxxxx.com/xxxxxxxmp3", "");


This starts the station nicely, but the browser pops up and covers the game (which runs in a window). I have tried various command switches to start the browser minimised, this works with Chrome if the browser is not yet running... but what if Chrome is not installed? Edge comes with Win10 but I couldn't get it to run minimised, similar troubles with iexplorer.exe

Ideally the station should start without a browser popping up at all, but I could live with the browser if it can be forced to minimise and open the station in a new tab.

Any help would be most welcome.

Thanks,
Gabor

PS: AGS is wonderful, thanks for all the time, effort and expertise people pour into it. I started long ago with a Commodore 64 and AGS has brought back my memories... invaluable.

Sinitrena

I can't help with your problem, but I'd like to point out that I would consider such a feature a very questionable design choice. As a player, I would not want a game to open something I have no control over on the internet, especially when it is not directly affiliated with the game / game creator and when it is not necessary for the game to function. Leave my internet connections alone when you don't have a very good reason to use them!

Gabor

Good point. Once past the technical hurdle, at startup I would give the user the option in a GUI to start the radio, or even to choose from some stations. One of the options, possibly the default, would be not to start the radio.

Crimson Wizard

#3
Quote from: Gabor on Mon 01/02/2021 18:15:42
I thought it would be nice to launch an online radio station when the game starts, and it should stop when the game is closed.

So, there may be a problem with stopping it at closing the game. The thing is, AGS unfortunately still does not have a proper script function to be executed when the game is about to exit.

Indeed you may make a button that exits your game and react to that, but game may be closed by other means, e.g. pressing on window's x button, or hitting alt+f4. Even AGS's own alt+x game abort command will bypass any in-game gui functions.

I believe you may have to write a custom plugin that does this when it's unloaded.

Gabor

That leaves offering stations (or no radio) in a GUI at startup, with a note that the radio will open in the browser. This should also make it clear that stopping the radio is the player's job. The problem remains that the browser pops up on top of the game window... if minimising the default browser cannot be done from the script, is there any way to bring the AGS window to the front after the station is opened in the browser? Reaching out from AGS to Windows is probably as messy as detecting if the game window is being closed.

I have looked into writing some Delphi code but to my surprise playing a remote audio stream is not straightforward... I may have to read more on this.  ???

Crimson Wizard

Quote from: Gabor on Mon 01/02/2021 20:54:07is there any way to bring the AGS window to the front after the station is opened in the browser? Reaching out from AGS to Windows is probably as messy as detecting if the game window is being closed.

Not from the game script, but this again could be done with plugin, probably.
IIRC you dont have to detect that window is closed in plugin, as there was a plugin shutdown callback.
As for bringing window up front, I would not call that "messy" to do though :), but yes, one has to know how to work with WinAPI (and there's remaining a problem of supporting other systems like Linux, if you want to run there too).

eri0o

#6
I have recently looked into a REST client like plug-in based around libcurl for fetching data, similar to what's available on Game Maker Studio, it's not hard to do one. But on AGS there's no way to say "Play this stream of bytes" or something similar to what Dynamic Sprites are but for sound, so this is the part that such effort would fail.

Btw, somehow libcurl docs are easier to understand than Game Maker, so considering they use it I don't know why they distanced so much from it.

About opening a url in the browser some engines have a OpenURL function that is exclusively to that to avoid the game having full control on the computer - like AGS Shell. Love2D I know has such function and such function is also on SDL2.0.14 .

SMF spam blocked by CleanTalk