omxplayer的安装与使用
需要用python来控制播放视频,所以就找到了这个播放器,很好用。
看了官网文档,安装使用都写的比较明白了。
官网地址:https://python-omxplayer-wrapper.readthedocs.io/en/latest/#
安装:
pip3 install omxplayer-wrapper
使用:
from omxplayer import OMXPlayer
from pathlib import path
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN)
VIDEO_PATH = Path('my.mp4')
player = OMXPlayer(VIDEO_PATH, args = '-b -o local' )
while Ture:
if (GPIO.input(40) == GPIO.HIGH):
break
player.quit()
参数:
这些参数是在终端时候用的,在Python中如何使用,还需要摸索,但是一帮的可以加载args作为参数就能使用。
开始前:
omxplayer --help
Usage: omxplayer [OPTIONS] [FILE]
-h --help Print this help
-v --version