- Deux boutons pour augmenter ou diminuer le volume (html + JavaScript).
- Un sélecteur de radio.
Ce code fonctionne sous windows7 windows8 et windows10.
Code : Tout sélectionner
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