Connecting to the radio stream

Find quick help here to get you started with Hollywood
Post Reply
Bohun
Posts: 10
Joined: Sat Jul 16, 2016 8:34 am
Location: Poland

Connecting to the radio stream

Post by Bohun »

I tried to write a small program to listen to my favorite radio stations, but I failed at connecting to the servers. Maybe someone can point out where I'm going wrong, because unfortunately, I don't see it.

Code: Select all

@VERSION 11, 0
@REQUIRE "rapagui"
@DISPLAY {Hidden=True, Layers=True}

; Global variables
Local radio_urls = {
    "http://stream3.polskieradio.pl:8904/",
    "http://stream.357.pl:8000/357.mp3",
    "http://stream.nowyswiat.pl:8000/nowyswiat.mp3"
}

Local current_station = 0

; RapaGUI interface definition
Local gui_def$ = [[
<application id="app">
    <window title="Radio" notify="closerequest">
        <vgroup>
            <hgroup>
                <button id="button_trojka" notify="pressed">Troika</button>
                <button id="button_radio357" notify="pressed">Radio 357</button>
                <button id="button_nowyswiat" notify="pressed">Nowy Świat</button>
            </hgroup>
            <hgroup>
                <button id="button_stop" notify="pressed">Stop</button>
            </hgroup>
            <text id="current_station">Current station: None</text>
        </vgroup>
    </window>
</application>
]]

; Function to play a radio station
Function p_PlayStation(id)
    ; Stop any currently playing music
    StopMusic()
    current_station = id
    SetAttribute("current_station", "contents", "Current station: " .. radio_urls[id])

    ; Attempt to play the selected radio stream
    If Not PlayMusic(radio_urls[id])
        SetAttribute("current_station", "contents", "Current station: Playback error")
        DebugPrint("Error playing stream: " .. radio_urls[id])
    Else
        DebugPrint("Playing: " .. radio_urls[id])
    EndIf
EndFunction

; Function to stop playback
Function p_Stop()
    ; Stop the currently playing music
    StopMusic()
    SetAttribute("current_station", "contents", "Current station: None")
EndFunction

; Function to handle RapaGUI events
Function p_RapaGUIEvent(msg)
    Switch msg.Class
        Case "Window":
            If msg.Attribute = "CloseRequest"
                End
            EndIf
        Case "Button":
            Switch msg.ID
                Case "button_trojka":
                    p_PlayStation(0)
                Case "button_radio357":
                    p_PlayStation(1)
                Case "button_nowyswiat":
                    p_PlayStation(2)
                Case "button_stop":
                    p_Stop()
            EndSwitch
    EndSwitch
EndFunction

; Create GUI
moai.CreateApp(gui_def$)

; Install event handler
InstallEventHandler({RapaGUI = p_RapaGUIEvent})

; Main loop
Repeat
    WaitEvent
Forever
Bohun
Posts: 10
Joined: Sat Jul 16, 2016 8:34 am
Location: Poland

Re: Connecting to the radio stream

Post by Bohun »

Today I found httpstreamer plugin. Unfortunately it is not compatible with my mac M1. I there any chance to update this plugin for new MacOS?
Flinx
Posts: 354
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Connecting to the radio stream

Post by Flinx »

Bohun wrote: Thu Feb 26, 2026 11:00 pm Today I found httpstreamer plugin.
Don't expect too much. It would sometimes help to use the search function of this forum.
Anyone used Hollywood to play podcast?
Post Reply