0
我非常喜欢Python和Linux命令的noob,但我试图围绕它来包裹我的头。Python Mplayer脚本在播放时不运行
我的应用程序比这个示例大,但我想在扩展之前得到这个工作。
我在从模式下使用mplayer播放视频剪辑,但我想在剪辑完成时自动将其终止。所以我的想法是在slave模式下启动mplayer,然后命令'get_time_length',存储该值,为该值睡眠,杀死它并返回主例程。
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')
,我遇到的问题是,一旦视频片段开始播放,它永远不会在播放过程中运行的任何命令。我也不确定我的语法是否正确,以便检索命令行,但我至少想知道如何在播放视频时通过脚本向mplayer发送命令。
谢谢!