使用Python编程控制omxplayer播放视频的方式:
1、安装omxplayer
sudo apt-get install omxplayer
2、安装Python编程控制omxplayer所需要的依赖库文件
sudo apt install git virtualenv build-essential python3-dev libdbus-glib-1-dev libgirepository1.0-dev
3、使用pip或者pip3 install omxplayer库文件,下载地址:https://pypi.org/project/omxplayer-wrapper/#files
pip3 install omxplayer_wrapper-0.3.3-py2.py3-none-any.whl
4、编程示例。新建一个文件,写入下面代码,保存为.py文件。然后运行它即可。(F5)
from omxplayer import OMXPlayer
from pathlib import Path
from time import sleep
FILE_PATH = Path("/home/pi/Videos/真60hz.mp4")
mm = OMXPlayer(FILE_PATH)
sleep(25)
mm.quit()
----- The End.