I am very much a noob with Python and Linux commands but I'm trying to wrap my head around it.
My application is bigger than this sample but I am trying to get this working before expanding.
I am using mplayer in slave mode to play a video clip but I want to automatically kill it when the clip is done. So my idea is to start mplayer in slave mode then command 'get_time_length', store that value, sleep for that value, kill it and return to the main routine.
import os
import commands
import glob
#Global Commands
glcmd = 'get_time_length'
print("Preparing for kiosk mode! Press CTRL+C to exit")
try:
while 1:
path = '/media/*/button1/*'
os.system('mplayer -fs -quiet -slave path')
line = os.popen(glcmd).readline().strip() #Get the duration from mplayer
duration = line.split('=')[1] #Get just the length of video in Seconds
print(duration)
sleep(duration) #Wait until the video is done
os.system('quit')
The problem that I am having is that once the video clip starts playing, it never runs any commands during play. I'm also not sure if my syntax is right in order to retrieve the command line but I at least want to figure out how to be able to send commands with to mplayer with my script while a video is playing.
Thanks!