Page 1 of 1
Audio stream (shoutcast) playback - quick trick (Windows)
Posted: Sun Aug 14, 2016 4:45 pm
by firace
Code: Select all
H$ + "<meta http-equiv='X-UA-Compatible' content='IE=edge' />"
H$ + "<body bgcolor=black scroll=no><audio autoplay controls>"
H$ + "<source src='http://176.9.219.133:9998/stream'></audio>"
OpenWindow(0, 88, 244, 400, 140, "") : SetWindowColor(0,0)
WebGadget (0, 150, 000, 85, 80, "")
SetGadgetItemText(0, 1, H$)
Repeat : Until WaitWindowEvent() = 13116
Re: Audio stream (shoutcast) playback - quick trick (Windows
Posted: Sun Aug 14, 2016 5:43 pm
by Marc56us
Excellent !
I will (perhaps) adopt it for my software: exit the need of a DLL to play shoutcast.
Just need to find a way to adjust the volume without changing the overall volume.
Thanks for this trick

Re: Audio stream (shoutcast) playback - quick trick (Windows
Posted: Sun Aug 14, 2016 6:48 pm
by falsam
Thank for sharing.
I added two buttons to adjust the volume (step 0.1) and three radios
The initial volume set at 50%
Code: Select all
Enumeration window
#mainForm
EndEnumeration
Enumeration gadget
#audio
#stream
EndEnumeration
Declare loadStream()
Declare selectStream()
Global stream.s, HTML.s
OpenWindow(#mainForm, 88, 244, 190, 160, "Web Radio", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(#mainForm, RGB(0, 0, 0))
WebGadget (#audio, 0, 0, 170, 137, "")
ComboBoxGadget(#stream, 0, 137, 190, 23)
BindGadgetEvent(#stream, @selectStream(), #PB_EventType_Change)
loadStream()
SetGadgetState(#stream, 0)
selectStream()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Procedure loadStream()
Restore stream
For i = 0 To 3
Read.s title$
Read.s stream$
AddGadgetItem(#stream, -1, title$)
SetGadgetItemData(#stream, i, i)
Next
EndProcedure
Procedure selectStream()
Protected index = GetGadgetItemData(#stream, GetGadgetState(#stream)), n
Restore stream
For n = 0 To index
Read.s title$
Read.s stream$
Next
stream = stream$
;HTML
HTML = "<meta http-equiv='X-UA-Compatible' content='IE=edge' />"
HTML + "<body bgcolor=black scroll=no>"
HTML + "<audio id = 'stream' autoplay controls>"
HTML + "<source src='" + stream + "'>"
HTML + "</audio>"
HTML + "<p style='padding-left: 40px'>"
HTML + "<button onclick='subtractVolume()' type='button' style= 'width: 50px; height: 24px' title='Volume -0.1'>-</button>"
HTML + "<button onclick='addVolume()' type='button' style= 'width: 50px; height: 24px' title='Volume +0.1'>+</button>"
HTML + "</p>"
;Script
HTML + "<script>"
HTML + "var audio = document.getElementById('stream');"
HTML + "audio.volume = 0.5;"
HTML + "function addVolume() { if (audio.volume + 0.1 < 1.0) { audio.volume += 0.1;} }"
HTML + "function subtractVolume() { if (audio.volume - 0.1 > 0) { audio.volume -= 0.1;} }"
HTML + "</script>"
SetGadgetItemText(#audio, #PB_Web_HtmlCode , HTML)
EndProcedure
DataSection
stream:
Data.s "Deep link NYC", "http://176.9.219.133:9998/stream"
Data.s "DI Radio", "http://5.39.71.159:8110/stream"
Data.s "Club hits", "http://178.32.62.172:9371/stream"
Data.s "Creek Valley Radio", "http://192.99.34.205:8356/stream"
EndDataSection
Re: Audio stream (shoutcast) playback - quick trick (Windows
Posted: Sun Aug 14, 2016 8:40 pm
by Derren
Cool. If it'sjust an html5 audio element, you can find lots of code to add controls, like a real volume slider using JS and CSS online.
thanks for posting.
Nice stream as well
