piplayer3 working!
This commit is contained in:
+15
-14
@@ -7,16 +7,17 @@ import subprocess
|
||||
import select # for polling zbarcam, see http://stackoverflow.com/a/10759061/3761783
|
||||
import os
|
||||
import requests
|
||||
import urllib
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s - %(message)s')
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s - %(message)s')
|
||||
logging.info('Initializing')
|
||||
|
||||
# Configuration
|
||||
MUSIC_BASE_DIRECTORY = "/home/pi/music/"
|
||||
SOUND_SCANNING = "/home/pi/piplayer2/sounds/scanning.mp3"
|
||||
SOUND_OK = "/home/pi/piplayer2/sounds/ok-05.mp3"
|
||||
SOUND_SCAN_FAIL = "/home/pi/piplayer2/sounds/fail-05.mp3"
|
||||
SOUND_PLAYBACK_ERROR = "/home/pi/piplayer2/sounds/error.mp3"
|
||||
MUSIC_BASE_DIRECTORY = "/media/share/Kinder/"
|
||||
SOUND_SCANNING = "file:///home/pi/sounds/scanning.mp3"
|
||||
SOUND_OK = "file:///home/pi/sounds/ok.mp3"
|
||||
SOUND_SCAN_FAIL = "file:///home/pi/sounds/fail.mp3"
|
||||
SOUND_PLAYBACK_ERROR = "file:///home/pi/sounds/error.mp3"
|
||||
QR_SCANNER_TIMEOUT = 3
|
||||
|
||||
MOPIDY_URL = 'http://127.0.0.1:6680/mopidy/rpc'
|
||||
@@ -51,10 +52,6 @@ GPIO.setup(PIN_PREV, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
GPIO.setup(PIN_PLAY, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
GPIO.setup(PIN_NEXT, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
|
||||
GPIO.add_event_detect(PIN_PREV, GPIO.FALLING, callback=btn1_callback, bouncetime=400)
|
||||
GPIO.add_event_detect(PIN_PLAY, GPIO.FALLING, callback=btn2_callback, bouncetime=400)
|
||||
GPIO.add_event_detect(PIN_NEXT, GPIO.FALLING, callback=btn3_callback, bouncetime=400)
|
||||
|
||||
|
||||
|
||||
def call(method, params=None):
|
||||
@@ -73,6 +70,7 @@ def add_uri(filename):
|
||||
|
||||
def play_sound(filename):
|
||||
call('core.tracklist.clear')
|
||||
logging.debug('Cleared tracklist, adding ' + filename)
|
||||
add_uri(filename)
|
||||
call('core.playback.play')
|
||||
|
||||
@@ -107,6 +105,10 @@ def btn3_callback(channel):
|
||||
call('core.playback.next')
|
||||
|
||||
|
||||
GPIO.add_event_detect(PIN_PREV, GPIO.FALLING, callback=btn1_callback, bouncetime=400)
|
||||
GPIO.add_event_detect(PIN_PLAY, GPIO.FALLING, callback=btn2_callback, bouncetime=400)
|
||||
GPIO.add_event_detect(PIN_NEXT, GPIO.FALLING, callback=btn3_callback, bouncetime=400)
|
||||
|
||||
|
||||
try:
|
||||
play_sound(SOUND_OK)
|
||||
@@ -146,7 +148,7 @@ try:
|
||||
qr_code = qr_code.decode("utf-8") # python3
|
||||
logging.info("QR Code: " + qr_code)
|
||||
|
||||
if (not qr_code.startswith("http://", "spotify:")):
|
||||
if (not (qr_code.startswith("http://") or qr_code.startswith("spotify:"))):
|
||||
# create full path
|
||||
full_path = MUSIC_BASE_DIRECTORY + qr_code
|
||||
|
||||
@@ -155,12 +157,11 @@ try:
|
||||
filenames = list_files(full_path)
|
||||
for filename in filenames:
|
||||
if filename.lower().endswith(MUSIC_EXTENSIONS):
|
||||
file_uri = 'file://' + filename
|
||||
add_uri(file_uri)
|
||||
add_uri("file://" + urllib.parse.quote(filename))
|
||||
|
||||
else:
|
||||
logging.debug("It's a file")
|
||||
add_uri("file://" + full_path)
|
||||
add_uri("file://" + urllib.parse.quote(full_path))
|
||||
|
||||
else:
|
||||
logging.debug("URL, open directly")
|
||||
|
||||
@@ -1,29 +1,139 @@
|
||||
# To Do
|
||||
|
||||
## mopidy / spotify
|
||||
https://docs.mopidy.com/en/latest/installation/
|
||||
### Installation
|
||||
|
||||
https://www.raspberrypi.org/documentation/remote-access/ssh/ --> file "ssh" on boot partition
|
||||
|
||||
[basic setup]
|
||||
|
||||
sudo apt-get install python-pip
|
||||
sudo apt-get install python3-pip
|
||||
sudo pip3 install requests
|
||||
|
||||
curl https://get.pimoroni.com/phatdac | bash
|
||||
--> reboot
|
||||
--> test curl https://get.pimoroni.com/phatdac | bash
|
||||
|
||||
nach https://docs.mopidy.com/en/latest/installation/
|
||||
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
|
||||
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install mopidy
|
||||
|
||||
nach https://github.com/mopidy/mopidy-spotify#installation
|
||||
sudo apt-get install mopidy-spotify
|
||||
https://github.com/mopidy/mopidy-spotify --> Configuration
|
||||
https://www.mopidy.com/authenticate/#spotify
|
||||
|
||||
https://docs.mopidy.com/en/latest/ext/web/#mopidy-api-explorer
|
||||
pip install Mopidy-API-Explorer
|
||||
sudo pip install Mopidy-API-Explorer
|
||||
--> http://localhost:6680/api_explorer/
|
||||
|
||||
Dokumentation:
|
||||
sudo apt-get install ncmpcpp
|
||||
|
||||
--> https://www.mopidy.com/authenticate/#spotify
|
||||
|
||||
|
||||
|
||||
### installation for user pi
|
||||
# create config
|
||||
mopidy config
|
||||
nano ~/.config/mopidy/mopidy.conf
|
||||
|
||||
|
||||
[http]
|
||||
hostname = ::
|
||||
|
||||
[local]
|
||||
enabled = false
|
||||
|
||||
[spotify]
|
||||
username = tliero@gmx.net
|
||||
password = ********
|
||||
client_id = <ID from authentication>
|
||||
client_secret = <secret from authentication>
|
||||
|
||||
#[spotify_web]
|
||||
#client_id = <ID from authentication>
|
||||
#client_secret = <secret from authentication
|
||||
|
||||
nach https://github.com/pimusicbox/mopidy-musicbox-webclient#installation
|
||||
pip install mopidy-musicbox-webclient
|
||||
|
||||
|
||||
### Service einrichten (https://docs.mopidy.com/en/latest/service/)
|
||||
sudo mopidyctl config
|
||||
|
||||
sudo nano /etc/mopidy/mopidy.conf
|
||||
[http]
|
||||
hostname = ::
|
||||
static_dir = /opt/webclient
|
||||
|
||||
[local]
|
||||
enabled = false
|
||||
|
||||
[spotify]
|
||||
username = tliero@gmx.net
|
||||
password = ********
|
||||
client_id = <ID from authentication>
|
||||
client_secret = <secret from authentication>
|
||||
|
||||
sudo systemctl enable mopidy
|
||||
sudo reboot
|
||||
sudo systemctl status mopidy
|
||||
--> http://192.168.1.142:6680/mopidy/
|
||||
|
||||
|
||||
sudo apt-get install git
|
||||
|
||||
|
||||
### moped web client https://github.com/martijnboland/moped
|
||||
sudo mkdir /opt/webclient
|
||||
cd /opt/webclient
|
||||
sudo git clone https://github.com/martijnboland/moped.git
|
||||
sudo mv moped/dist/* .
|
||||
cd ..
|
||||
sudo chown -R mopidy webclient
|
||||
sudo service mopidy restart
|
||||
--> http://192.168.1.142:6680/
|
||||
|
||||
### alternativ: musicbox web client https://github.com/pimusicbox/mopidy-musicbox-webclient
|
||||
sudo mkdir /opt/mopidy-musicbox-webclient
|
||||
cd /opt/mopidy-musicbox-webclient/
|
||||
sudo git clone https://github.com/pimusicbox/mopidy-musicbox-webclient
|
||||
cd mopidy-musicbox-webclient
|
||||
sudo python setup.py install
|
||||
cd ..
|
||||
sudo mv mopidy-musicbox-webclient/dist/* .
|
||||
cd ..
|
||||
sudo chown -R mopidy mopidy-musicbox-webclient
|
||||
sudo service mopidy restart
|
||||
--> http://192.168.1.142:6680/musicbox_webclient/
|
||||
|
||||
|
||||
sudo mkdir /media/share
|
||||
sudo chmod 777 /media/share
|
||||
sudo nano /etc/rc.local
|
||||
# mount share
|
||||
sudo mount -t cifs -o user=guest,password= //192.168.1.110/hidrive/Media/Audio /home/pi/share
|
||||
#sudo mount -t cifs -o user=guest,password= //192.168.1.125/hidrive/Media/Audio /media/share
|
||||
sudo reboot
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### mopidy Dokumentation
|
||||
http://localhost:6680/api_explorer/#/library.search
|
||||
https://docs.mopidy.com/en/latest/api/core/#mopidy.core.mopidy.core.LibraryController
|
||||
|
||||
https://docs.mopidy.com/en/latest/ext/file/
|
||||
|
||||
ncmpcpp
|
||||
https://docs.mopidy.com/en/latest/service/
|
||||
|
||||
### ncmpcpp
|
||||
sudo apt-get install ncmpcpp
|
||||
https://wiki.archlinux.org/index.php/ncmpcpp#Basic_usage
|
||||
|
||||
### JSON-RPC
|
||||
|
||||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.describe"}' http://127.0.0.1:6680/mopidy/rpc
|
||||
|
||||
@@ -40,6 +150,15 @@ curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "m
|
||||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.playback.play"}' http://127.0.0.1:6680/mopidy/rpc
|
||||
|
||||
|
||||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "file:///media/share/Singles/04%20-%20The%20Funeral.mp3"}}' http://192.168.1.142:6680/mopidy/rpc
|
||||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "file:///home/pi/sounds/scanning.mp3"}}' http://192.168.1.142:6680/mopidy/rpc
|
||||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "http://www.wdr.de/wdrlive/media/kiraka.m3u"}}' http://192.168.1.142:6680/mopidy/rpc
|
||||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "spotify:user:tliero:playlist:08pbBkT5Vd2xXhxrMCVbAH"}}' http://192.168.1.142:6680/mopidy/rpc
|
||||
|
||||
|
||||
|
||||
|
||||
### Spotify URLs
|
||||
https://open.spotify.com/track/3jQyadhLTxpxadQlkFh2b8
|
||||
https://open.spotify.com/episode/1o8HWRR0mx5TfyxLlnKv8e
|
||||
https://open.spotify.com/show/4zQKHBLkM3puG5n3jAU2H4
|
||||
@@ -47,7 +166,6 @@ https://open.spotify.com/album/0BajiiFeEZv9eEx07Hw2C0
|
||||
|
||||
|
||||
|
||||
|
||||
## Hardware
|
||||
- PHAT DAC installieren - http://www.instructables.com/id/Multiroom-Client-With-Raspberry-Pi-ZERO-and-PHAT-D/?ALLSTEPS
|
||||
- Lautstärke über IR regeln
|
||||
|
||||
Reference in New Issue
Block a user