dzVents and mplayer streams (listed in process status, no sound)

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Fisk
Posts: 2
Joined: Sunday 09 May 2021 19:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

dzVents and mplayer streams (listed in process status, no sound)

Post by Fisk »

Hello everyone!
I just tried to fix my problem, but i failed. It worked before. I have two scripts - one for selecting radio, second for setting volume level. Codes below.
When I select radio i can see it via process list( ps aux). When i run this commands in terminal it works normally(I hear the sound). I'm not sure its a problem with something ala DISPLAY:0 command, but I don't know. I updated Domoticz but it don't fix the problem. Hope someone know the cause. Thank You!

Code: Select all

-- This script play a streaming radio when the device is changed
-- Start files with "mplayer -noconsolecontrols radiostation.mp3 &> /dev/null"
-- Start playlists with "mplayer -noconsolecontrols -playlist radiostation.m3u &> /dev/null"

return {
	on = {
		devices = {
			'Radio'
		}
	},
	execute = function(domoticz, device)

    if  device.state == 'Off' then
        os.execute ("killall mplayer")      
    end
    
    if  device.state ~= 'Off' then
    	 -- domoticz.helpers.btspeaker(domoticz, 'On') -- BTAudio on
        if device.state == 'Afera' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols https://radio.afera.com.pl/afera128.mp3 -volume 70 &> /dev/null")
        end
        
        if device.state == 'Kaszebe' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols https://stream3.nadaje.com:8048/ -volume 70 &> /dev/null")
        end
        
        if device.state == 'RMF FM' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://217.74.72.10:8000/rmf_fm -volume 70 &> /dev/null")
        end
        
        if device.state == 'Zet' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://zt04.cdn.eurozet.pl/zet-old.mp3 -volume 50 &> /dev/null")
        end
        if device.state == 'Radio 357' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://stream.open.fm/357 -volume 50 &> /dev/null")
        end
		
		
	    if device.state == 'RMF FM Fitness' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://31.192.216.8/FITNESS -volume 50 &> /dev/null")
        end
		
	    if device.state == 'link' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols link -volume 50 &> /dev/null")
        end
		
    	if device.state == 'Muzyka Filmowa' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://195.150.20.8:8000/rmf_muzyka_filmowa -volume 50 &> /dev/null")
        end
		
    	if device.state == 'Zet Hits' then
            os.execute ("killall mplayer")
            os.execute ("mplayer -noconsolecontrols http://zt.cdn.eurozet.pl/ZETHIT.mp3 -volume 50 &> /dev/null")
        end	
    end

end
}

Script for setting volume:

Code: Select all

return {
	on = {
		devices = {
			'Volume'
		}
	},
	execute = function(domoticz, device)

        if  device.state ~= 'Off' then
    	 -- domoticz.helpers.btspeaker(domoticz, 'On') -- BTAudio on
        if device.state == 'Volume +' then
            os.execute ("amixer set Master 10%+")
                    end
        
        if device.state == 'Volume -' then
            os.execute ("amixer set Master 10%-")
                    end
        
        if device.state == 'Mute' then
            os.execute ("amixer set Master toggle")
        end
        
    end

end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents and mplayer streams (listed in process status, no sound)

Post by waaren »

Fisk wrote: Sunday 09 May 2021 19:30 just tried to fix my problem, but i failed. It worked before. I have two scripts - one for selecting radio, second for setting volume level. Codes below.
When I select radio i can see it via process list( ps aux). When i run this commands in terminal it works normally(I hear the sound). I'm not sure its a problem with something ala DISPLAY:0 command, but I don't know. I updated Domoticz but it don't fix the problem. Hope someone know the cause.
If you replace the first script with below version it will show more information what happens.

Code: Select all

-- This script play a streaming radio when the device is changed
-- Start files with "mplayer -noconsolecontrols radiostation.mp3"
-- Start playlists with "mplayer -noconsolecontrols -playlist radiostation.m3u"

local scriptVar = 'mplayer'

return
{
    on =
    {
        devices =
        {
            'Radio',
        },
        shellCommandResponses =
        {
            scriptVar,
        },
    },

    logging =
    {
        domoticz.LOG_DEBUG,
        marker = scriptVar,
    },

    execute = function(dz, item)

        local function mPlayerCommand(cmd)
            dz.executeShellCommand(
            {
                command = "killall mplayer; " .. ( cmd or '') ,
                callback = scriptVar,
                timeout = 20,
            })
        end
        if item.isShellCommandResponse then
            dz.utils.dumpTable(item)
            return
        end

        if  item.state == 'Off' then
            mPlayerCommand()
        else
            dz.log('item.state is ' .. item.state, dz.LOG_DEBUG)
            		
             -- dz.helpers.btspeaker(dz, 'On') -- BTAudio on
            if item.state == 'Afera' then
                mPlayerCommand("mplayer -noconsolecontrols https://radio.afera.com.pl/afera128.mp3 -volume 70")
            elseif item.state == 'Kaszebe' then
                mPlayerCommand("mplayer -noconsolecontrols https://stream3.nadaje.com:8048/ -volume 70")
            elseif item.state == 'RMF FM' then
                mPlayerCommand("mplayer -noconsolecontrols http://217.74.72.10:8000/rmf_fm -volume 70")
            elseif item.state == 'Zet' then
                mPlayerCommand("mplayer -noconsolecontrols http://zt04.cdn.eurozet.pl/zet-old.mp3 -volume 50")
            elseif item.state == 'Radio 357' then
                mPlayerCommand("mplayer -noconsolecontrols http://stream.open.fm/357 -volume 50")
            elseif item.state == 'RMF FM Fitness' then
                mPlayerCommand("mplayer -noconsolecontrols http://31.192.216.8/FITNESS -volume 50")
            elseif item.state == 'link' then
                mPlayerCommand("mplayer -noconsolecontrols link -volume 50")
            elseif item.state == 'Muzyka Filmowa' then
                mPlayerCommand("mplayer -noconsolecontrols http://195.150.20.8:8000/rmf_muzyka_filmowa -volume 50")
            elseif item.state == 'Zet Hits' then
                mPlayerCommand("mplayer -noconsolecontrols http://zt.cdn.eurozet.pl/ZETHIT.mp3 -volume 50")
            end
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Fisk
Posts: 2
Joined: Sunday 09 May 2021 19:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: dzVents and mplayer streams (listed in process status, no sound)

Post by Fisk »

The Domoticz log output after Your script i named Radio2. The First is disabled.

Code: Select all

2021-05-10 17:24:22.089 Radio: Light/Switch (Radio)
2021-05-10 17:24:22.074 Status: User: Admin (IP: 192.168.1.201) initiated a switch command (18/Radio/Set Level)
2021-05-10 17:24:22.201 Status: dzVents: Info: Handling events for: "Radio", value: "Kaszebe"
2021-05-10 17:24:22.201 Status: dzVents: Info: mplayer: ------ Start internal script: Radio2: Device: "Radio (Radio)", Index: 18
2021-05-10 17:24:22.201 Status: dzVents: Info: mplayer: ------ Finished Radio2
2021-05-10 17:24:22.201 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-05-10 17:24:22.712 Status: dzVents: Info: Handling shellcommandResponse-events for: "mplayer"
2021-05-10 17:24:22.712 Status: dzVents: Info: mplayer: ------ Start internal script: Radio2: ShellCommandResponse: "mplayer"
2021-05-10 17:24:22.712 Status: dzVents: > data: MPlayer 1.3.0 (Debian), built with gcc-8 (C) 2000-2016 MPlayer Team
2021-05-10 17:24:22.712
2021-05-10 17:24:22.712 Playing https://stream3.nadaje.com:8048/.
2021-05-10 17:24:22.712 libavformat version 58.20.100 (external)
2021-05-10 17:24:22.712
2021-05-10 17:24:22.712
2021-05-10 17:24:22.712 Exiting... (End of file)
2021-05-10 17:24:22.712 Status: dzVents: > baseType: shellcommandResponse
2021-05-10 17:24:22.712 Status: dzVents: > statusText: mplayer: nie znaleziono żadnego procesudo_connect: could not connect to socketconnect: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.[tls @ 0xb6855e1c]Error in the pull function.Failed to open https://stream3.nadaje.com:8048/.
2021-05-10 17:24:22.712 Status: dzVents: > timeoutOccurred: false
2021-05-10 17:24:22.712 Status: dzVents: > isScene: false
2021-05-10 17:24:22.712 Status: dzVents: > dump()
2021-05-10 17:24:22.712 Status: dzVents: > ok: true
2021-05-10 17:24:22.712 Status: dzVents: > lines:
2021-05-10 17:24:22.712 Status: dzVents: > 1: MPlayer 1.3.0 (Debian), built with gcc-8 (C) 2000-2016 MPlayer Team
2021-05-10 17:24:22.712 Status: dzVents: > 2: Playing https://stream3.nadaje.com:8048/.
2021-05-10 17:24:22.713 Status: dzVents: > 3: libavformat version 58.20.100 (external)
2021-05-10 17:24:22.713 Status: dzVents: > 4: Exiting... (End of file)
2021-05-10 17:24:22.713 Status: dzVents: > isGroup: false
2021-05-10 17:24:22.713 Status: dzVents: > isDevice: false
2021-05-10 17:24:22.713 Status: dzVents: > errorText: mplayer: nie znaleziono żadnego procesudo_connect: could not connect to socketconnect: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.[tls @ 0xb6855e1c]Error in the pull function.Failed to open https://stream3.nadaje.com:8048/.
2021-05-10 17:24:22.713 Status: dzVents: > isJSON: false
2021-05-10 17:24:22.713 Status: dzVents: > isHardware: false
2021-05-10 17:24:22.713 Status: dzVents: > isHTTPResponse: false
2021-05-10 17:24:22.713 Status: dzVents: > isSystem: false
2021-05-10 17:24:22.713 Status: dzVents: > isXML: false
2021-05-10 17:24:22.713 Status: dzVents: > isSecurity: false
2021-05-10 17:24:22.713 Status: dzVents: > isVariable: false
2021-05-10 17:24:22.713 Status: dzVents: > isTimer: false
2021-05-10 17:24:22.713 Status: dzVents: > isCustomEvent: false
2021-05-10 17:24:22.713 Status: dzVents: > hasLines: true
2021-05-10 17:24:22.713 Status: dzVents: > statusCode: 0
2021-05-10 17:24:22.713 Status: dzVents: > trigger: mplayer
2021-05-10 17:24:22.713 Status: dzVents: > shellCommandResponse: mplayer
2021-05-10 17:24:22.713 Status: dzVents: > isShellCommandResponse: true
2021-05-10 17:24:22.713 Status: dzVents: > callback: mplayer
2021-05-10 17:24:22.713 Status: dzVents: Info: mplayer: ------ Finished Radio2
No in process status while selected "kaszebe" radio.

When I set switch for "RMF FM" radio, I can see mplayer process, but no sound
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest