Hey, Fourdee thanks for the assistance! I followed it but ended up with:
root@DietPi:~# systemctl status mplayer_script.sh -l
● mplayer_script.sh.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Which is strange because if I just copy and paste
root@DietPi:~#/root/mplayer_script.sh
it’ll start playing the video. Could it be root privileges?
● myscript.service - myscript
Loaded: loaded (/etc/systemd/system/myscript.service; enabled)
Active: active (exited) since Thu 2016-11-03 05:02:49 GMT; 10min ago
Process: 1186 ExecStart=/bin/bash -c /root/mplayer_script.sh (code=exited, status=0/SUCCESS)
Main PID: 1186 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/myscript.service
Nov 03 05:02:47 DietPi systemd[1]: Starting myscript...
Nov 03 05:02:49 DietPi bash[1186]: Cannot find HOME directory.
Nov 03 05:02:49 DietPi bash[1186]: MPlayer2 2.0-728-g2c378c7-4 (C) 2000-2012 MPlayer Team
Nov 03 05:02:49 DietPi bash[1186]: Terminal type `unknown' is not defined.
Nov 03 05:02:49 DietPi bash[1186]: Playing big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4.
Nov 03 05:02:49 DietPi bash[1186]: Cannot open file 'big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4': No such file or directory
Nov 03 05:02:49 DietPi bash[1186]: Failed to open big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4.
Nov 03 05:02:49 DietPi bash[1186]: Dead key input on file descriptor 0
Nov 03 05:02:49 DietPi bash[1186]: Exiting... (End of file)
Nov 03 05:02:49 DietPi systemd[1]: Started myscript.
So it does run the script, but when its run it can’t see root directory or any contents. Is it because myscript.service is being run outside of root access?
Sorry for the late reply, went through exams and my image was corrupted so I went back and remade it.
Some of the names have changed but much the same as before.
On the plus side when I rebooted the audio was playing but the video didn’t show, so that’s positive step forward .
This is the output from the script.
Thanks again!
root@DietPi:~# systemctl status myscript.service -l
● myscript.service - myscript
Loaded: loaded (/etc/systemd/system/myscript.service; enabled)
Active: activating (start) since Wed 2016-11-30 00:17:38 GMT; 2min 27s ago
Main PID: 908 (mplayer-play.sh)
CGroup: /system.slice/myscript.service
├─908 /bin/sh /EBTV/mplayer-play.sh
└─911 mplayer -fs -autosync 50 -mc 1.5 -vo vdpau -vc ffmpeg12vdpau,ff h264vdpau,ffhevcvdpau, /EBTV/big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4 -loop 0
Nov 30 00:19:10 DietPi bash[908]: [2.0K blob data]
Nov 30 00:19:16 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:23 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:28 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:33 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:39 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:46 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:52 DietPi bash[908]: [1.9K blob data]
Nov 30 00:19:58 DietPi bash[908]: [1.9K blob data]
Nov 30 00:20:04 DietPi bash[908]: [1.9K blob data]
Mplayer should work on fbdev, so not sure why there is no video. Does the video work when you run from the cmdline? Might also be SystemD, try adding StandardOutput=tty under the [Service] section of the service.
Failing that, lets try X11, change your script so that xinit is called, before mplayer, eg:
I gave that a shot and ended up with some fatal errors in the log lol (x11 was installed).
But that’s all good, when I watched the boot I noticed the audio would begin to play before the boot messages would finish and the desktop would eventually load. I decided to add a sleep 60 to the beginning of my script and when it rolled around it all loaded up correctly.
Its hacky as all hell and the OCD part of me would like something more concrete but I am happy that it loads , thank you for your help Fourdee, really do appreciate it.
Not sure if there is a way to tell myscript.services to wait until x11 has loaded or potentially some other processes so it runs once all other processes are operational?
after I get this baby operational I’ll be moving on to playing with cloud stuff
Not sure if there is a way to tell myscript.services to wait until x11 has loaded or potentially some other processes so it runs once all other processes are operational?
Yep, is your systemD service currently set to After=graphical.target?
>
> If > After=graphical.target > isnt waiting for X11, you can add some code to your script that will wait for the X11 process to start, eg (untested):
>
> ```text
# - Wait for X11 process to run
while (( ! $(ps aux | grep -ci -m1 '[X]11') ))
do
# - wait 3 seconds before checking again
sleep 3
done
play movie
Yep After=graphical.target is set in myscript.service, it doesn’t appear to be waiting.
Had to modify your script slightly to ( !(ps aux | grep -ci -m1 ‘11’) ) it works!
Didn’t see the desktop before the video started to play, feels good hehe.