Spotify / Chromecast Integration [Headless songs abspielen]

Begonnen von stetaba, 19 Februar 2017, 19:30:33

Vorheriges Thema - Nächstes Thema

stetaba

Hallo zusammen,

anbei eine kurze Anleitung zur Integration von Spotify und Chromecast (Ich hoffe ich kriege noch alle Schritte zusammen. Ansonsten bitte melden, dann ergänze ich). Im Grunde genommen wollte ich folgendes Szenario realisieren: Schalten eines Homematic Aktors: Starten einer bestimmten Spotify Playlist und Wiedergabe auf einem bestimmten Chromecast Device (z.B. Wohnzimmer). Für dieses Setup habe ich folgenden Weg gewählt:

Mopidy (https://www.mopidy.com/) - Mächtiger Music Player mit Spotify, SoundCloud und GMusic Integration. Verfügt zudem über ein MPD Interface und lässt sich damit über FHEM steuern.
Icecast2 (http://icecast.org/) - Erzeugung eines Netzwerkstreams der Mopidy Ausgabe. Mopidy kommt mit einer Icecast Erweiterung.
Chromecast FHEM Modul von Dominik (https://forum.fhem.de/index.php?topic=45505.0) - Ermöglicht das Streamen beliebiger Webstreams auf Chromecast Devices.

Chromecast modul wie im Forum beschrieben installieren.

Installation Icecast und lame:

sudo apt-get install icecast2 lame

Runterladen einer silence mp3 datei um den stream bei pausen nicht zu stoppen:

wget http://jetcityorange.com/silent-ringtone/silence-10sec.mp3
sudo mv silence-10sec.mp3 /usr/share/icecast2/web
sudo chown icecast2 /usr/share/icecast2/web/silence-10sec.mp3


Danach die icecast2 config anpassen und einen mopidy stream mountpoint einfügen

<mount>
  <mount-name>/mopidy</mount-name>
  <fallback-mount>/silence-10sec.mp3</fallback-mount>
  <fallback-override>1</fallback-override>
</mount>


und icecast neu starten:

sudo /etc/init.d/icecast2 restart

Danch solltet ihr icecast über den browser öffnen können: http://ipdespi:8000. Die streams werden erst bei aktiver audio wiedergabe angezeigt.


Installation Mopidy:


sudo apt-get update
sudo apt-get install mopidy mopidy-spotify mopidy-alsamixer



Dazu noch eine Weboberfläche:


pip install Mopidy-Mopify


Danach müsst ihr noch eine config datei für den mopidy service anlegen und danach den mopidy user als owner eintragen:


sudo nano /etc/mopidy/mopidy.conf
sudo chown mopidy /etc/mopidy/mopidy.conf




[http]
#enabled = true
hostname = ::
#port = 6680
static_dir = /opt/webclient
#zeroconf = Mopidy HTTP server on $hostname

[spotify]
username = email@gmail.com
password = *****

[mpd]
enabled = true
hostname = 0.0.0.0
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist = listall,listallinfo
default_playlist_scheme = m3u
mpd/enabled

[audio]
mixer = software
mixer_volume = 100
output = lamemp3enc ! shout2send mount=mopidy ip=127.0.0.1 port=8001 password=hackme
visualizer =

[alsamixer]
enabled = true
card = 1
control = PCM



Danach noch mopidy als service installieren und starten:


sudo dpkg-reconfigure mopidy
sudo service mopidy start


Danach solltet Ihr euch unter http://ipdespi:6680/mopify anmelden können und die Mopify Oberfläche sehen. Ggf. muss man sich hier nochmal bei Spotify authentifizieren um alle tracks sehen zu können.

Wenn ihr jetzt icecast aufruft sollte dort einen stream mopidy zu finden sein. Den könnt ihr dann im Chromecast modul hinterlegen und ans chromecast streamen.

mdp in FHEM
MDP Player in FHEM anlegen
define myMPD MPD 127.0.0.1 6600
  Dann noch das attribut player auf mopidy setzen. Danach kann man in FHEM spotify titel ansteuern:
set myMPD play spotify:album:79OIuUUBPHDm5OVvET9zop


Was noch offen ist:

Rel. hohe cpu auslastung 50-70%
Startup skripte, so dass icecast for mopidy gestartet wird.
Beim weiterschalten eines Tracks verliert der chromecast die stream verbindung und muss neu gestartet werden.
Chromecast bug wenn chromecast device vom strom getrennt wird ist die verbindung weg


Danach solltet Ihr euch unter http://ipdespi:6680/mopify anmelden können und die Mopify Oberfläche sehen. Ggf. muss man sich hier nochmal bei Spotify authentifizieren um alle tracks sehen zu können.

Wenn ihr jetzt icecast aufruft sollte dort einen stream mopidy zu finden sein. Den könnt ihr dann im Chromecast modul hinterlegen und ans chromecast streamen.

Badflex

#1
Hallo,wolte es mal nach der Anleitung installieren.
Leider kommt bei mir immer der fehler E: Paket mopidy-spotify kann nicht gefunden werden.
Woran kann das liegen?

Edit:

Habs mit:
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

und dann:

apt-get update && apt-get dist-upgrade && apt-get install  mopidy mopidy-spotify mopidy-alsamixer

geschaft.
Raspberry Pi, CUL868(SlowRF), FB 7490, SmartVisu, fast nur HomeMatic wenig FS20, Netatmo

stetaba

Hi,

vilt habe ich noch was vergessen. Versuche vorher mal:

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




Badflex

#3
Danke,grade selbst gefunden :-)

Wie kann ich es anstellen das ich den Stream auf meinem Tablet hören kann und über bluetooth an die box ohne cromecast?
Raspberry Pi, CUL868(SlowRF), FB 7490, SmartVisu, fast nur HomeMatic wenig FS20, Netatmo

stetaba

Icecast mp3 Stream auf Tablet öffnen und dann die Ausgabe auf Bluetooth stellen.

Badflex

irgendetws stimmt bei mir nicht.
Wenn ich in Puddy mopidy eingebe kommt das:
pi@raspberrypi:~ $ mopidy
INFO     Starting Mopidy 2.1.0
INFO     Loading config from builtin defaults
INFO     Loading config from /home/pi/.config/mopidy/mopidy.conf
INFO     Loading config from command line options
INFO     Enabled extensions: mopify, mpd, alsamixer, http, stream, m3u, softwaremixer, file
INFO     Disabled extensions: spotify, local
WARNING  Found local configuration errors, the extension has been automatically disabled:
WARNING    local/media_dir must be set.
WARNING  Found spotify configuration errors, the extension has been automatically disabled:
WARNING    spotify/username must be set.
WARNING    spotify/password must be set.
WARNING  Please fix the extension configuration errors or disable the extensions to silence these messages.
INFO     Starting Mopidy mixer: SoftwareMixer
INFO     Starting Mopidy audio
INFO     Starting Mopidy backends: StreamBackend, M3UBackend, FileBackend
INFO     Audio output set to "autoaudiosink"
INFO     Starting Mopidy core
INFO     Starting Mopidy frontends: QueueManagerFrontend, MpdFrontend, HttpFrontend
ERROR    Frontend (MpdFrontend) initialization error: MPD server startup failed: [Errno 98] Address already in use
ERROR    Frontend (HttpFrontend) initialization error: HTTP server startup failed: [Errno 98] Address already in use
INFO     Starting GLib mainloop
INFO     Starting Mopidy 2.1.0
INFO     Loading config from builtin defaults
INFO     Loading config from /home/pi/.config/mopidy/mopidy.conf
INFO     Loading config from command line options
INFO     Enabled extensions: mopify, mpd, alsamixer, http, stream, m3u, softwaremixer, file
INFO     Disabled extensions: spotify, local
WARNING  Found local configuration errors, the extension has been automatically disabled:
WARNING    local/media_dir must be set.
WARNING  Found spotify configuration errors, the extension has been automatically disabled:
WARNING    spotify/username must be set.
WARNING    spotify/password must be set.
WARNING  Please fix the extension configuration errors or disable the extensions to silence these messages.
INFO     Starting Mopidy mixer: SoftwareMixer
INFO     Starting Mopidy audio
INFO     Starting Mopidy backends: StreamBackend, M3UBackend, FileBackend
INFO     Audio output set to "autoaudiosink"
INFO     Starting Mopidy core
INFO     Starting Mopidy frontends: QueueManagerFrontend, MpdFrontend, HttpFrontend
ERROR    Frontend (MpdFrontend) initialization error: MPD server startup failed: [Errno 98] Address already in use
ERROR    Frontend (HttpFrontend) initialization error: HTTP server startup failed: [Errno 98] Address already in use
INFO     Starting GLib mainloop


Habe aber die config so geändert.
Mopidy geht auch auf und ich sehe meine spotify lieder. Aber ich höre nix wenn ich play mache.
habe einen Latsprecher an den pi angeschlossen.

Icecast zeit bei mir garnichts an.

Weil ich nicht alle pakete installieren konnte habe ich also root angemeldet und dort auch mopidy installiert.
Wenn ich vi /home/pi/.config/mopidy/mopidy.conf
kommt noch eine ander config.

# For further information about options in this file see:
#   http://docs.mopidy.com/
#
# The initial commented out values reflect the defaults as of:
#   Mopidy 2.1.0
#   Mopidy-ALSAMixer 1.0.3
#   Mopidy-File 2.1.0
#   Mopidy-HTTP 2.1.0
#   Mopidy-Local 2.1.0
#   Mopidy-M3U 2.1.0
#   Mopidy-MPD 2.1.0
#   Mopidy-Mopify 1.6.0
#   Mopidy-SoftwareMixer 2.1.0
#   Mopidy-Spotify 3.0.0
#   Mopidy-Stream 2.1.0
#
# Available options and defaults might have changed since then,
# run `mopidy config` to see the current effective config and
# `mopidy --version` to check the current version.

[core]
#cache_dir = $XDG_CACHE_DIR/mopidy
#config_dir = $XDG_CONFIG_DIR/mopidy
#data_dir = $XDG_DATA_DIR/mopidy
#max_tracklist_length = 10000
#restore_state = false

[logging]
#color = true
#console_format = %(levelname)-8s %(message)s
#debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
#debug_file = mopidy.log
#config_file =

[audio]
#mixer = software
#mixer_volume =
#output = autoaudiosink
#buffer_time =

[proxy]
#scheme =
#hostname =
#port =
#username =
#password =

[mopify]
#enabled = true
#debug = false

[mpd]
#enabled = true
#hostname = 127.0.0.1
#port = 6600
#password =
#max_connections = 20
#connection_timeout = 60
#zeroconf = Mopidy MPD server on $hostname
#command_blacklist =
#  listall
#  listallinfo
#default_playlist_scheme = m3u

[http]
#enabled = true
#hostname = 127.0.0.1
#port = 6680
#static_dir =
#zeroconf = Mopidy HTTP server on $hostname

[stream]
#enabled = true
#protocols =
#  http
#  https
#  mms
#  rtmp
#  rtmps
#  rtsp
#metadata_blacklist =
#timeout = 5000

[m3u]
#enabled = true
#base_dir =
#default_encoding = latin-1
#default_extension = .m3u8
#playlists_dir =

[softwaremixer]
#enabled = true

[file]
#enabled = true
#media_dirs =
#  $XDG_MUSIC_DIR|Music
#  ~/|Home
#excluded_file_extensions =
#  .jpg
#  .jpeg
#show_dotfiles = false
#follow_symlinks = false
#metadata_timeout = 1000

[local]
#enabled = true
#library = json
#media_dir =
#scan_timeout = 1000
#scan_flush_threshold = 100
#scan_follow_symlinks = false
#excluded_file_extensions =
#  .directory
#  .html
#  .jpeg
#  .jpg
#  .log
#  .nfo
#  .png
#  .txt

[spotify]
#enabled = true
#username =
#password =
#bitrate = 160
#volume_normalization = true
#private_session = false
#timeout = 10
#allow_cache = true
#allow_network = true
#allow_playlists = true
#search_album_count = 20
#search_artist_count = 10
#search_track_count = 50
#toplist_countries =

[alsamixer]
#enabled = true
#card = 0
#control = Master



muss ich hier auch was machen'?
Raspberry Pi, CUL868(SlowRF), FB 7490, SmartVisu, fast nur HomeMatic wenig FS20, Netatmo

stetaba

Hi,

Das sieht aus als sei Mopidy mehrfach gestartet. Versuch es am besten über den Service wie oben beschrieben. Du siehst erst einen Icecast stream, wenn ein Titel über die Mopidy Oberfläche gestartet ist.
Wichtig ist das in Mopidy config
output = lamemp3enc ! shout2send mount=mopidy ip=127.0.0.1 port=8000

Gesetzt ist.

Badflex

#7
Der Port war es.
Oben stand Port 8001.
Das habe ich übersehen :)
Raspberry Pi, CUL868(SlowRF), FB 7490, SmartVisu, fast nur HomeMatic wenig FS20, Netatmo

febus

Moin,

irgendeine Idee, wie ich diesen Fehler auf meinem RPi beheben kann?

ERROR    Failed to create audio output "lamemp3enc ! shout2send mount=mopidy ip=127.0.0.1 port=8000 password=nohack": gst_parse_error: no element "lamemp3enc" (1)

Viele Grüße,
Marc

Esjay

Zitat von: febus am 06 Oktober 2017, 13:39:16
Moin,

irgendeine Idee, wie ich diesen Fehler auf meinem RPi beheben kann?

ERROR    Failed to create audio output "lamemp3enc ! shout2send mount=mopidy ip=127.0.0.1 port=8000 password=nohack": gst_parse_error: no element "lamemp3enc" (1)

Es gibt mittlerweile ein extra Modul für Spotify, vll ist das ja eher etwas für dich.

https://forum.fhem.de/index.php/topic,72490.0.html

Grüße

benedikt-wue

Hallo,
ich habe zwar auch das "neue" Spotiy - Modul in Gebrauch, allerdings bekomme ich es da nicht hin, dass sich das Modul an die Geräte (in meinem Fall mehrere HomeMinis) "erinnert", heisst, ich muss sie immer erst aufwecken, dass ich in dem Spotify - Modul die Musik dann an das jeweilige Gerät "switchen" kann. Das Modul für GoogleCast habe ich auch in Verwendung, aber da hilft es leider nichts, wenn ich eine Spotify - Playlist angebe, er spielt sie nicht ab. Daher dachte ich, ich könnt hier auf diesem Weg weiterkommen eben mit dem MPD - Modul. Leider scheitert das bereits an Mopidy, da ich Python - V 3.5.3 habe und Mopidy nach Phyton -V 2.7 weint und somit nicht startet. Hat da jemand eine Idee für mich? :-)
Danke schon im Voraus und schöne Grüße
Ben

Abercrombie1892

wie ist denn die qualität, wenn man über icecast den stream an den chromecast übergibt?