按下按钮后 Omxplayer 崩溃我喜欢用按钮更改电影,这是我目前拥有的代码,但按下几个按钮后 Omxplayer 崩溃!我是树莓派的新手,python 一直在寻找修复但找不到任何东西。欢迎任何帮助。
我得到的错误是:
Traceback (most recent call last):
File "mygpio.py", line 34, in <module>
player.load(vida)
File "build/bdist.linux-armv7l/egg/omxplayer/player.py", line 162, in load
File "build/bdist.linux-armv7l/egg/omxplayer/player.py", line 88, in _load_source
File "build/bdist.linux-armv7l/egg/omxplayer/player.py", line 134, in _setup_dbus_connection
SystemError: DBus cannot connect to the OMXPlayer process
#!/usr/bin/env python2
import os.path
from time import sleep
import subprocess
import os
from omxplayer import OMXPlayer
vida = '/home/pi/Videos/testvids/6.mov'
vidb = '/home/pi/Videos/testvids/3.mov'
vidc = '/home/pi/Videos/testvids/t2.mp4'
default = '/home/pi/Videos/testvids/t1.mp4'
import RPi.GPIO as GPIO
#set up GPIO using BCM numbering
GPIO.setmode(GPIO.BCM)
#All Gpio's as input and pull up
GPIO.setup(2, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_UP)
player = OMXPlayer(default,args=['--no-osd','--blank'],)
while True:
if GPIO.input(2) ==0:
player.load(vida)
print("gpio 2")
player.play()
#sleep(5)
if (GPIO.input(3) == 0):
player.load(vidb)
print("gpio 3")
player.play()
# sleep(5)
if (GPIO.input(4) == 0):
player.load(vidc)
print("gpio 4")
player.play()
#sleep(5)
GPIO.cleanup()