It sounded easy but I have been searching and struggling to find the correct solution and was hoping someone could steer me in the right direction.
This code below works fine when I ssh into my headless Pi
- Code: Select all
#! /usr/bin/env python
# play mp3 from cron task
# Import moduals and functions
import os, sys
os.system('omxplayer -o local Lithium.mp3')
sys.exit()
But when I set cron to run it say every 5 mins it does not work.
- Code: Select all
*/5 * * * * python /home/pi/music/mp3.py &>/dev/null
After searching around I seem to think it should be run as some sort of sub-process??? I have tried various bit of code such as popen() and call() to no avail.
Could somebody tell me if I heading in the right direction with sub-processes and if so which one I should be looking to use.
Or is this just not possible.
I wanted it to be part of a bigger script that downloads a text file with the song to play from a remote webserver and then plays that song and deletes the file from the server.
I have the other parts working but can not get the song to play because no terminal window is open on the Raspberry Pi.
I have also try with Mplayer and Pygaame.
Thanks for reading Kyle.