I found some excellent code to play internet radio by
vuott
here and
here. I thought I would make a few changes! (Press [F11] for full-screen mode).
' Gambas class file
'' Requires gb.media
Private TextArea1 As TextArea
Private DrawingArea1 As DrawingArea
Private ToggleButton1 As ToggleButton
Private ButtonDisplay As Button
Private HBox1 As HBox
Private Splitter1 As Splitter
Private mp As MediaPlayer
Private Meta As New Collection
Private ss As New String[]
Private iDisplay As Integer
Private tipoPlug As String[] = ["goom", "monoscope", "spacescope", "spectrascope", "synaescope", "wavescope"]
Private plugVis As MediaControl
Public Sub Form_Open()
Dim iSH As Integer = Screen.AvailableHeight
Dim iSW As Integer = Screen.AvailableWidth
If Not Component.IsLoaded("gb.settings") Then Component.Load("gb.settings")
iDisplay = Settings["display", 0]
With Me
.Arrangement = Arrange.Vertical
.Padding = 5
.H = iSH * 0.73
.W = iSW * 0.6
End With
DrawingArea1 = New DrawingArea(Me)
DrawingArea1.Expand = True
DrawingArea1.Tooltip = "Press F11 to toggle fullscreen"
With HBox1 = New HBox(Me)
.Padding = 5
.H = iSH * 0.05
.Invert = True
End With
With ToggleButton1 = New ToggleButton(HBox1) As "ToggleButton1"
.W = iSW * 0.07
.Foreground = Color.Green
.Font.Size = 12
.Font.Bold = True
.Text = "&Start"
End With
With ButtonDisplay = New Button(HBox1) As "ButtonDisplay"
.W = iSW * 0.07
.Foreground = Color.Green
.Font.Size = 12
.Font.Bold = True
.Text = "&Display"
End With
ToggleButton1_Click(True)
End
Public Sub ButtonDisplay_Click()
Inc iDisplay
If iDisplay > 5 Then iDisplay = 0
ToggleButton1_Click
ToggleButton1_Click(True)
Settings["display"] = iDisplay
Settings.Save
End
Public Sub ToggleButton1_Click(Optional bSkip As Boolean)
If ToggleButton1.Value Or bSkip = True Then
ToggleButton1.Value = True
With mp = New MediaPlayer As "MediaPlayer1"
plugVis = New MediaControl(mp, tipoPlug[iDisplay])
.Video.Output = New MediaControl(mp, "ximagesink")
.SetWindow(DrawingArea1)
.URL = "https://icy.unitedradio.it/VirginRock70.mp3"
.Play
.Video.Visualisation = plugVis
End With
ToggleButton1.Foreground = Color.Red
ToggleButton1.Text = "&Stop"
Else
mp.Stop
mp.Close
ToggleButton1.Foreground = Color.Green
ToggleButton1.Text = "&Start"
Endif
End
Public Sub MediaPlayer1_Tag(tagList As MediaTagList)
Dim sSplit As String[]
For Each tag As String In tagList.Tags
If Not Meta.Exist(tag) Then
Meta[tag] = tagList[tag]
ss.Push(tag)
ss.Push(tagList[tag])
Else
ss[ss.Find(tag) + 1] = tagList[tag]
Endif
Next
If ss.Find("title") > 1 Then
sSplit = Split(ss[ss.Find("title") + 1], "~", "", True)
Me.Title = sSplit[0] & ", " & sSplit[1] & " (" & sSplit[2] & ")"
End If
End
Public Sub Form_KeyRelease()
If Key.code = Key["F11"] Then
If Me.Border = True Then
Settings.Write(Me.Window)
Settings.Save
Me.border = False
Me.Maximized = True
Me.padding = 0
HBox1.Visible = False
Else
Me.border = True
Me.Maximized = False
HBox1.Visible = True
Me.padding = 5
Settings.Read(Me.Window)
Me.Refresh
Wait
Endif
Endif
End
Public Sub MediaPlayer1_End()
ToggleButton1.Value = False
End