我用python播放歌曲。我使用了omxplayer。但是当我运行它会停止并终止没有任何错误。它运行几个循环。有时超过20次。 请帮我找错。
#
# Copyright 2015 <pi@raspberrypi>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
import os,signal
import thread
import time
import dbus
import subprocess
import logging
def main():
logging.basicConfig(format='%(levelname)s:%(message)s:%(asctime)s',filename='example.log',filemode='w',level=logging.DEBUG)
out=""
file="/home/pi/Desktop/song/BnS\ -\ Master\ Sir.mp3"
path= "omxplayer %s" %(file)
while(True):
try:
logging.info('Started')
subprocess.call(path,shell=True)
logging.info('Finished')
#os.system(path)
except:
print "error on subprocess call"
logging.error("cant open")
logging.info('end of while')
return 0
if __name__ == '__main__':
main()