forked from server/soundboard
Use DBus to spawn omxplayer for planned controls
This commit is contained in:
parent
7d6c5410c4
commit
b817b1b3b5
@ -13,14 +13,14 @@ Requirements
|
|||||||
|
|
||||||
.. code::
|
.. code::
|
||||||
|
|
||||||
apt install espeak omxplayer python3.4 python3-pip
|
apt install espeak omxplayer python3.4 python3-pip python3-dbus
|
||||||
pip3 install virtualenv youtube-dl
|
pip3 install virtualenv youtube-dl
|
||||||
|
|
||||||
It is highly recommended to install the soundboard and its dependencies into a virtual environment to keep the system clean. To do so first create a new virtual environment in the desired folder and install the remaining Python dependencies via the `pip` of the virtualenv:
|
It is highly recommended to install the soundboard and its dependencies into a virtual environment to keep the system clean. To do so first create a new virtual environment in the desired folder and install the remaining Python dependencies via the `pip` of the virtualenv:
|
||||||
|
|
||||||
.. code::
|
.. code::
|
||||||
|
|
||||||
virtualenv py
|
virtualenv --system-site-packages py
|
||||||
py/bin/pip install -r requirements.txt
|
py/bin/pip install -r requirements.txt
|
||||||
|
|
||||||
Apache
|
Apache
|
||||||
|
|||||||
@ -1,6 +1,14 @@
|
|||||||
|
certifi==2017.7.27.1
|
||||||
|
chardet==3.0.4
|
||||||
click==6.7
|
click==6.7
|
||||||
|
decorator==4.2.1
|
||||||
|
evento==1.0.1
|
||||||
Flask==0.12.2
|
Flask==0.12.2
|
||||||
|
idna==2.6
|
||||||
itsdangerous==0.24
|
itsdangerous==0.24
|
||||||
Jinja2==2.9.6
|
Jinja2==2.9.6
|
||||||
MarkupSafe==1.0
|
MarkupSafe==1.0
|
||||||
|
omxplayer-wrapper==0.2.5
|
||||||
|
requests==2.18.4
|
||||||
|
urllib3==1.22
|
||||||
Werkzeug==0.12.2
|
Werkzeug==0.12.2
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import subprocess
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, g, jsonify
|
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, g, jsonify
|
||||||
|
from omxplayer import *
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ def index(sound=None, text=None, video=None):
|
|||||||
tags = queryDB("SELECT name FROM tag ORDER BY name COLLATE NOCASE")
|
tags = queryDB("SELECT name FROM tag ORDER BY name COLLATE NOCASE")
|
||||||
|
|
||||||
if sound is not None and sound in sounds:
|
if sound is not None and sound in sounds:
|
||||||
subprocess.Popen(["omxplayer", os.path.join(config.path, sound).encode("utf-8")], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
player.OMXPlayer(os.path.join(config.path, sound).encode("utf-8"))
|
||||||
|
|
||||||
if text is None:
|
if text is None:
|
||||||
text = request.form.get("text")
|
text = request.form.get("text")
|
||||||
@ -74,11 +75,11 @@ def index(sound=None, text=None, video=None):
|
|||||||
|
|
||||||
if video is not None:
|
if video is not None:
|
||||||
if video[-4:] == ".mp3":
|
if video[-4:] == ".mp3":
|
||||||
subprocess.Popen(["omxplayer", video], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
player.OMXPlayer(video)
|
||||||
else:
|
else:
|
||||||
url = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode()
|
urls = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode().split("\n")
|
||||||
subprocess.Popen(["omxplayer", url.split("\n")[1]])
|
for url in urls:
|
||||||
subprocess.Popen(["omxplayer", "-b", url.split("\n")[0]])
|
player.OMXPlayer(url)
|
||||||
|
|
||||||
killvideo = request.args.get("killvideo")
|
killvideo = request.args.get("killvideo")
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ def sounds(name):
|
|||||||
def play_random():
|
def play_random():
|
||||||
sounds = [os.fsencode(file).decode() for file in os.listdir(config.path)]
|
sounds = [os.fsencode(file).decode() for file in os.listdir(config.path)]
|
||||||
random_sound = random.sample(sounds, 1)[0]
|
random_sound = random.sample(sounds, 1)[0]
|
||||||
subprocess.Popen(["omxplayer", os.path.join(config.path, random_sound).encode("utf-8")], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
player.OMXPlayer(os.path.join(config.path, random_sound).encode("utf-8"))
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|
||||||
@app.route("/tags/<tags>")
|
@app.route("/tags/<tags>")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user