User mods, screenshots & videos > Other

embed live webaudiostreams in outerra

(1/2) > >>

fly77:
Here is an example mod that retrieves web audiostreams from the web and plays them inside outerra.
Only web audiostreams that "autoplay" when the URL of the stream is pasted into a browser do work.

The mod plays just one fixed radiostation set in the first line of the script "webAudioStreamExample.js"
and its purpose is just to show how commands can be used inside mod scripts to embed live web audiostreams inside outerra.

By inspecting the javascript file "webAudioStreamExample.js" that you find in the
"username/Outerra/packages/fly77/radiolina"  folder you can learn which commands are available and how to use them.
Given the purpose of this mod the script is intentionally kept very basic.

note that the commands require my fly77_plugin.dll to be installed in outerra (see below).


Download from here:

https://drive.google.com/drive/folders/1tSfnBGLoc-DPQ_tRS_H75UZV_NYmn2ky?usp=sharing


installation:
there are two files : fly77_plugin.dll  and radiolina.otx
1) drop fly77_plugin.dll  into Anteworld/plugins folder  ! (not in the username/Outerra/plugins one)
2) click on self-installing radiolina.otx file


use:
you can find the mod under vehicles as "radiolina"
spawn it and while still inside the radio press L to switch the radio ON and L again to switch it off.
You will hear the fixed web audiostream of WBGO Jazz 88.3 FM - Newark, NJ  radio
which has audiostream URL

http://wbgo.streamguys.net/wbgo96
 
you can hear the same by just pasting this URL in a browser.
Note that it will autoplay without requiring you to press any play button.

You can experiment by substituting different web audiostream URLs in the first line of the mod script




andfly:
Very, very interesting and well done!
Effective for the intended purpose.
Thanks for sharing.

And now ... (huh, huh ... were you hoping to get away with it?) Million-dollar question ...
I noticed that, in addition to commanding the execution of the audio stream, you are also able to send get requests and obtain data in response:
$ plugin.get_web_audiostream_info ();
$ plugin.get_web_playlist_info ();
$ plugin.get_web_media_info ();
$ plugin.get_waveaudio_device_info ();
All these requests are addressed in order to obtain objects with the characteristics required by the audio stream.

Would it be possible to write a "universal" function that makes a "get" call to a website and gets json data or a text string in response, at the user's discretion?

Let me explain better with an example, for me, very current.
In the simulation program of the ISS I need to obtain the starting data for the calculation of the position and speed of the station.
Through the plugin I execute a command:  system (" curl -s -o "+ Path +" iss2.txt https://api.wheretheiss.at/v1/satellites/25544/tles ");
Basically I ask, through a system call, to the windows program curl.exe, to make a "get" call to the "wheretheiss.at" site and to write the answer in the "iss2.txt" file. Then I read the file through the plugin and transport the data that interests me "cleaned up" in the main program.
All this is extremely inelegant and, even if it achieves the intended purpose, it unnecessarily complicates the procedure.
Moreover, it causes the program to be interrupted for about a second, waiting for the answer and for the conclusion of the "system" call.

Unfortunately, I haven't found another more direct way.
The study of the routines that communicate with the Web in the Outerra API and the attempt to include the CURL project in the plugin have not been successful, due to my lack of knowledge of the C ++ language. Again I had to "get around" the problem with a trick.

A universal "get" function would be very useful to anyone wishing to communicate with the Web from within Outerra and without consulting external programs.

Thank you for your attention.   :)

fly77:

--- Quote from: andfly on March 23, 2022, 05:51:27 am ---..And now ... (huh, huh ... were you hoping to get away with it?) Million-dollar question ...
...Would it be possible to write a "universal" function that makes a "get" call to a website and gets json data or a text string in response, at the user's discretion?

--- End quote ---

huh..difficult but fascinating.. I'll try to include the curl inside the c++ plugin
This link seems to provide an example. I'll let you know

http://www.cplusplus.com/forum/windows/36638/

fly77:
The first step is to get curl built and seen in visual studio (I use visual studio 2019 comunity edition)
This worked perfectly for me.
https://stackoverflow.com/questions/53861300/how-do-you-properly-install-libcurl-for-use-in-visual-studio-2017
since for outerra we need the 64 version of curl the commands I did in cmd window are :

    Get latest vcpkg zip file from https://github.com/microsoft/vcpkg/releases (e.g. https://github.com/microsoft/vcpkg/archive/2019.09.zip) and extract it to a folder of your choice (e.g. C:\vcpkg\)
    Open Developer Command Prompt and cd to C:\vcpkg\
    Run bootstrap-vcpkg.bat
    Run vcpkg.exe integrate install
    Run vcpkg install curl:x64-windows
    Create a new C++ project in Visual Studio and you're ready to go


Then you need to set the include and library directories as well as linker additional library dependencies in visual studio for your plugin :

In Project Properties -> VC++ Directories -> Include Directories add C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\include\
In Project Properties -> VC++ Directories -> Library Directories add C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\lib\ there
In Project Properties -> Linker -> Input -> Additional Dependencies add libcurl_a.lib, Ws2_32.lib, Crypt32.lib, Wldap32.lib and Normaliz.lib

finally in the plugin hpp obviously add the include:

#define CURL_STATICLIB
#include "CURL/curl.h"

The plugin compiles fine in 64 bit.

now comes the other part ..what to do with it....I'll let you know if I can create the curl HTML GET command there..



andfly:
I was going to reply with "curl" already up and running but ... I can't find the time and I have to keep putting it off.
In the meantime, however, I would like to congratulate you on the excellent and very fast work.
With such detailed instructions I think it will all be very easy.

And, of course, thank you so much !!    :D :D

Navigation

[0] Message Index

[#] Next page

Go to full version