@nikolov do you have more info?
How does your rules look?
How do you execute mplayer?
The most common rule error is not using absolute path’s. For example; execute "radio.sh"
should be execute "/home/pi/radio.sh"
Radio Stream ButtonDevice
@nikolov do you have more info?
How does your rules look?
How do you execute mplayer?
The most common rule error is not using absolute path’s. For example; execute "radio.sh"
should be execute "/home/pi/radio.sh"
yeah, first i thought also something like that, but i’ve really tried all possibilities. i can start mplayer from pimatic rule with no problem, but if i start it that way, it dont listen to the pipe…
to start i use these rule:
execute "mkfifo /tmp/fifofile" and execute "mplayer -slave -input file=/tmp/fifofile http://stream.laut.fm/charon"
for change volume that:
execute "echo volume -1 >> /tmp/fifofile"
ps: how can i post code in this forum??
@nikolov said in Radio Stream ButtonDevice:
ps: how can i post code in this forum??
https://forum.pimatic.org/topic/1179/how-to-post-code-snippets-and-alike-on-the-forum
execute “mkfifo /tmp/fifofile” and execute “mplayer -slave -input file=/tmp/fifofile http://stream.laut.fm/charon”
It is not a goof idea to have two execute commands as they will be executed in parallel and this may override the fifofile which in turn causes mplayer to listen on stale socket. The next problem is that the mplayer does not terminate. Therefore you should send it to the background and make sure to kill dangling processes
Try the following:
execute "killall mplayer && rm -f /tmp/fifofile && mkfifo /tmp/fifofile && mplayer -slave -input file=/tmp/fifofile http://stream.laut.fm/charon > /dev/null 2>&1 &"
Note beyond you can also switch the station via the command fifo. For example:
echo "loadfile http://radioeins.de/stream" >> /tmp/fifofile
I just verified this in my test setup and it works great. Please let me know if you need further advice
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
thank a lot for your response mate
@mwittig said in Radio Stream ButtonDevice:
It is not a goof idea to have two execute commands
to rule that out, i activated the sequential mode in the plugin settings for shell-execute
if i did it with your command and there are no mplayer instances running or no fifofile it will error and dont execute.
if i start mplayer with
execute "mkfifo /tmp/fifofile && mplayer -slave -input file=/tmp/fifofile http://stream.laut.fm/charon > /dev/null 2>&1 &"
the sound start, but i cant command mplayer with writing the fifo file, not with a rule, and not with a terminal. if i try to change it in a terminal like that:
echo volume +1 >> /tmp/fifofile
the terminal freeze till i strg+c
but if i start the mplayer not with a pimatic rule but in a terminal it works perfectly, this way i can change the volume perfectly with pimatic…
i also try it with a root session, because the fifo file which is created from pimatic i think belongs to root, but also no success
@mwittig said in Radio Stream ButtonDevice:
I just verified this in my test setup and it works great. Please let me know if you need further advice
nearly can’t belive that I’m trying to get that shit run for a really long time since now, with different raspberries and vanilla installations…
big thanks anyway to you
@nikolov said in Radio Stream ButtonDevice:
nearly can’t belive that
Here is my test setup. Unfortunately, pimatic does not have an import feature, but it is relatively easy to use the configuration editor to add the snippets if you want to give it a try. Watch out for missing commans before/after the items if there are items preceding/following the inserted snippets.
Buttons-Device
{
"buttons": [
{
"id": "radio-on",
"text": "On"
},
{
"id": "radio-off",
"text": "Off"
},
{
"id": "radio-volume-up",
"text": "+"
},
{
"id": "radio-volume-down",
"text": "-"
}
],
"id": "radio",
"name": "radio",
"class": "ButtonsDevice"
}
Rules
{
"id": "radio-on",
"name": "radio-on",
"rule": "when radio-on is pressed then execute \"killall mplayer && rm -f /tmp/fifofile && mkfifo /tmp/fifofile && mplayer -slave -input file=/tmp/fifofile http://stream.laut.fm/charon > /dev/null 2>&1 &\"",
"active": true,
"logging": true
},
{
"id": "radio-off",
"name": "radio-off",
"rule": "when radio-off is pressed then execute \"echo stop >> /tmp/fifofile\"",
"active": true,
"logging": true
},
{
"id": "radio-volume-up",
"name": "radio-volume-up",
"rule": "when radio-volume-up is pressed then execute \"echo volume +1 >> /tmp/fifofile\"",
"active": true,
"logging": true
},
{
"id": "radio-volume-down",
"name": "radio-volume-down",
"rule": "when radio-volume-down is pressed then execute \"echo volume -1 >> /tmp/fifofile\"",
"active": true,
"logging": true
}
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@mwittig i’ve inserted the snipped in my config and rebooted. if i hit radio on, nothing happens, i think the reason is that the first command throws out an error like that:
mplayer: Kein Prozess gefunden
so the rest of the command isnt executed.
if i add a fifofile and start a mplayer instance, i can hit the radio on button and the radio starts like planned, but it don’t react to the other buttons
i’m running the 9.42 version, you think that could be a problem?
do you have a special setting for the shell-execute plugin?
@nikolov alright, so i have installed mplayer and tried your example @mwittig and it also locks my system up… This works for me though;
killall mplayer && rm -r /tmp/my.fifo && mkfifo /tmp/my.fifo && mplayer -slave -input file=/tmp/my.fifo http://stream.laut.fm/charon > /dev/null 2>&1 &
Now it doesnt lock up and a test rule to change the volume:
execute "echo volume -1 >> /tmp/my.fifo"
worked perfectly…
@gleno0h Did you also activate sequential mode like @Nikolov did which I did not do in my test case.
It didn’t lock up in my setup, but I must admit that killall mplayer
did not kill all mplayer threads as expected. So process entries and space may pile up and some fine tuning is required.
EDIT: @Glenoth, imho using rm -r
does not make much sense here as a recursive removal is not applicable. I am using rm - f
to make sure the command never prompts (if interactive mode is set by system default) and to ignore nonexistent files.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@mwittig no it is using default setting for the shell sensor plugin.
Yeah you are right about the rm -r, old habbits
@Gleno0h also your rule to start the player just works for me if i manually create a fifofile and mplayer instance.
if i dont create that befor i press the on button pimatic starts crying like this:
error [pimatic-shell-execute]: [ShellActionHandler] stderr output from command killall mplayer && rm -r /tmp/my.fifo && mkfifo /tmp/my.fifo && mplayer -slave -input file=/tmp/my.fifo http://stream.laut.fm/charon > /dev/null 2>&1 &: mplayer: Kein Prozess gefunden
i also deactivate the sequential setting in the plugin with no effect.
and if i create the files to start the radio, same thing with the controlings, from pimatic with rule nothing works and if testing in terminal, it freezes like before…