this is a simple project I did some time ago, just to demonstrate what is possible to do with Annex using GUI, events and buttons.
Luckily I found a backup of the project on my old disk.
So, you'll find here a .zip file containing all the files for the project.
Probably the list of the web radio must be updated as this project is around 2 years old.
Code: [Local Link Removed for Guests]
'Annex Web radio Player demo by cicciocb 2020
''''''''''''''''''''''''''''''''''''''
'data "Galaxie Radio", "https://listen.radioking.com/radio/15684/stream/29075"
data "Beatles Radio", "http://www.beatlesradio.com:8000/stream/1/"
data "Radio Funky", "http://streaming.hotmixradio.fm/hotmixradio-funky-128.mp3"
data "Classis Rock", "http://classicrock.stream.ouifm.fr/ouifm3.mp3"
data "Blue Rock", "http://bluesnrock.stream.ouifm.fr/ouifmbluesnrock-128.mp3"
data "Jazz Radio Funk", "http://jazz-wr06.ice.infomaniak.ch/jazz-wr06-128.mp3"
data "Latina", "http://start-latina.ice.infomaniak.ch/start-latina-high.mp3"
data "Radio Marte", "http://onair18.xdevel.com:8212/"
data "Rai Radio 1", "http://icestreaming.rai.it/1.mp3"
data "Funky", "http://allzic08.ice.infomaniak.ch/allzic11.mp3"
data "Italo Disco", "http://streams.80s80s.de/italohits/mp3-192/streams.80s80s.de/"
data "end"
data "Rai Radio 1", "http://icestreaming.rai.it/1.mp3"
data "Rai Radio 2", "http://icestreaming.rai.it/2.mp3"
data "Rai Radio 3", "http://icestreaming.rai.it/3.mp3"
data "Rai Radio 4", "http://icestreaming.rai.it/4.mp3"
data "Rai Radio 5", "http://icestreaming.rai.it/5.mp3"
data "Rai Radio 6", "http://icestreaming.rai.it/6.mp3"
data "Rai Radio 7", "http://icestreaming.rai.it/7.mp3"
data "Rai Radio 8", "http://icestreaming.rai.it/8.mp3"
data "Rai Radio 9", "http://icestreaming.rai.it/9.mp3"
data "Rai Radio 10", "http://icestreaming.rai.it/10.mp3"
data "Rai Radio 11", "http://icestreaming.rai.it/11.mp3"
data "Rai Radio 12", "http://icestreaming.rai.it/12.mp3"
data "Rai Radio 13", "http://icestreaming.rai.it/13.mp3"
data "Rai Radio 14", "http://icestreaming.rai.it/14.mp3"
data "Rai Radio 15", "http://icestreaming.rai.it/15.mp3"
data "Kiss Kiss", "http://ice07.fluidstream.net:8080/KissKiss.mp3"
data "Radio Marte", "http://onair18.xdevel.com:8212/"
data "Radio Zeta", "http://shoutcast.rtl.it:3030/" 'high rate 320 and https
data "Africa 1", "https://african1paris.ice.infomaniak.ch/african1paris-128.mp3"
data "Radio Pooh", "http://audio4.nemostream.tv:8011/autodj"
data "Rire et Chansons", "https://scdn.nrjaudio.fm/audio1/fr/30401/mp3_128.mp3"
data "NRJ Radio", "https://scdn.nrjaudio.fm/audio1/fr/30001/mp3_128.mp3"
data "end"
' pin for odroid GO
'IO36 Battery ADC
'IO39 BTN START
'IO34 BTN-AXIS X
'IO35 BTN-AXIS Y
'IO32 BTN A
'IO33 BTN B
'IO27 BTN SELECT
'IO13 BTN MENU
'IO00 BTN VOLUME
pin.mode 32, input, pullup ' BTN A
pin.mode 33, input, pullup ' BTN B
pin.mode 39, input, pullup ' BTN START
pin.mode 27, input, pullup ' BTN SELECT
pin.mode 13, input, pullup ' BTN MENU
pin.mode 00, input, pullup ' BTN VOLUME
'neo.setup 27, 1 ' set the neo rgb led on the pin 27
'neo.pixel 0, 12345
play.setup 0, 32 'use external DAC
pause 500
pin.mode 25, output ' full enable the audio amplifier
pin(25) = 1
brightness = 128
tft.brightness brightness
'neo.setup 12, 32 ' strip of 16 leds on pin 12
'neo.strip 0, 15, 0 ' clears all the led
dim radio$(100,2) ' max 100 radios
read r$
p = 0
while r$ <> "end"
radio$(p, 0) = r$
read radio$(p, 1)
read r$
p = p + 1
wend
nb_radios = p
wlog "nb radios "; nb_radios
current_radio = 0 ' file to be played
onplay play_event
gui.init 20
gui.image 0,0, 320, 240, "/img/landscapes/landscape6.jpg"
'main buttons
gui.box 0, 177, 320, 64, black, black, black
rew = gui.buttonimage 0, 177, 64, 64, "/icons/player/first2.bmp", "/icons/player/first.bmp", momentary, 0, black
ply = gui.buttonimage 70, 177, 64, 64, "/icons/player/play2.bmp", "/icons/player/play.bmp", momentary, 0, black
stp = gui.buttonimage 187, 177, 64, 64, "/icons/player/stop2.bmp", "/icons/player/stop.bmp", momentary, 0, black
ffw = gui.buttonimage 257, 177, 64, 64, "/icons/player/last2.bmp", "/icons/player/last.bmp", momentary, 0, black
'set events on buttons
gui.setevent rew, LEAVE, prev_radio
gui.setevent ply, LEAVE, play_radio
gui.setevent stp, LEAVE, stop_radio
gui.setevent ffw, LEAVE, next_radio
' volume
gui.textline 270, 5, 50, 14, "VOLUME"
vol = gui.slider 280, 20, 30, 150, 50, vertical
gui.setevent vol, 3, vol_change ' change event
gui.setstyle vol, 12, 6, 5
'vu meter
vu_L = gui.progressbar 240, 30, 10, 130, 50, 1
vu_R = gui.progressbar 260, 30, 10, 130, 50, 1
' window with the web radio information
tt = gui.textline 120, 0, 0, 0, "Radio" , 4, White, black, black
Sitename = gui.textline 5, 22, 220, 18, "Annex32 WiFi RDS Web Radio Player", 1, cyan, black, yellow
gui.textline 120, 60, 0, 0, " Genre Bitrate" , 4, White, black, black
Genre = gui.textline 5, 70, 140, 18, "by cicciocb", 1, cyan, black, yellow
Bitrate = gui.textline 155, 70, 70, 18, "2020", 1, cyan, black, yellow
gui.textline 120, 110, 0, 0, "Title Online" , 4, White, black, black
gui.rect 4, 121, 222, 36, white
title1= gui.textline 5, 122, 220, 18, "Listen Web Radios from Internet", 1, green, black, black
title2 = gui.textline 5, 138, 220, 18, "The whole code is around 100 lines!", 1, green, black, black
gui.autorefresh 50, 0 ' no touch
timer0 50, update_vu
timer1 100, update_buttons
wait
stop_radio:
play.stop
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
play_radio:
' set the default text in the boxes
gui.settext Sitename, radio$(current_radio, 0) ' radio name
gui.SetText Genre, "" 'empty
gui.SetText Bitrate, "" 'empty
split_text title1, title2, "" 'empty
if (play.isPlaying = 1) or (GUI.TARGET = ply) then
play.stop
play.stream radio$(current_radio, 1), 30000, 1
end if
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
prev_radio:
current_radio = current_radio -1
if current_radio < 0 then current_radio = nb_radios - 1
gosub play_radio
return
next_radio:
current_radio = current_radio + 1
if current_radio >= nb_radios then current_radio = 0
gosub play_radio
return
vol_change:
play.volume gui.getvalue(vol)
return
pos_change:
play.seek gui.getvalue(pos)
return
play_event:
pause 100
m$ = play.message$
print m$
SiteName$ = word.getparam$(m$, "SiteName")
Bitrate$ = word.getparam$(m$, "Bitrate")
Genre$ = word.getparam$(m$, "Genre")
Title$ = word.getparam$(m$, "StreamTitle")
if SiteName$ <> "" then gui.SetText Sitename, SiteName$
if Bitrate$ <> "" then gui.SetText Bitrate, Bitrate$ + " Kbps"
if Genre$ <> "" then gui.SetText Genre, Genre$
if Title$ <> "" then split_text title1, title2, Title$
return
update_slider:
gui.setvalue pos, play.pos
return
update_vu:
gui.setvalue vu_L, log(play.VU_L/300 + 1) * 26'* 24.88 computed value
gui.setvalue vu_R, log(play.VU_R/300 + 1) *26' * 24.88
l = log(play.VU_L/300 + 1)* 4 - 1
'neo.strip 0, 16, 0, 1
'neo.strip 0, l, neo.rgb(rnd(32), rnd(32), rnd(32))
return
sub split_text(obj1, obj2, txt$)
if len(txt$) < 35 then
gui.setText obj1, txt$
gui.setText obj2, " "
else
gui.setText obj1, left$(txt$, 35)
gui.setText obj2, mid$(txt$, 36)
end if
end sub
update_buttons:
gui.setvalue rew, 1 - pin(13)
gui.setvalue ply, 1 - pin(00)
gui.setvalue stp, 1 - pin(27)
gui.setvalue ffw, 1 - pin(39)
'volume with arrows up/down
y = adc(35)
if y > 0 then
v = gui.getvalue(vol)
if y < 4000 then
v = v - 1
else
v = v + 1
end if
if v > 100 then v = 100
if v < 0 then v = 0
gui.setvalue vol, v
play.volume v
end if
'brightness with arrows left/right
x = adc(34)
if x > 0 then
v = brightness
if x < 4000 then
v = v + 5
else
v = v - 5
end if
if v > 255 then v = 255
if v < 5 then v = 5
brightness = v
tft.brightness brightness
end if
return