{"id":7657,"date":"2020-12-08T17:13:54","date_gmt":"2020-12-08T16:13:54","guid":{"rendered":"https:\/\/andyland.info\/wordpress\/?p=7657"},"modified":"2021-01-04T18:26:25","modified_gmt":"2021-01-04T17:26:25","slug":"raspberry-pi-spotify-player","status":"publish","type":"post","link":"https:\/\/andyland.info\/wordpress\/raspberry-pi-spotify-player\/","title":{"rendered":"Raspberry Pi Spotify Player"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I built a Spotify-Player based on a Raspberry Pi 3 and Tizonia. It has 5 buttons to switch between different playlists and another button to skip to the next song in a playlist.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-1024x768.jpg\" alt=\"\" class=\"wp-image-7756\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-1024x768.jpg 1024w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-300x225.jpg 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-768x576.jpg 768w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-1536x1152.jpg 1536w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-2048x1536.jpg 2048w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-150x113.jpg 150w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_174306-200x150.jpg 200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-1024x768.jpg\" alt=\"\" class=\"wp-image-7754\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-1024x768.jpg 1024w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-300x225.jpg 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-768x576.jpg 768w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-1536x1152.jpg 1536w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-2048x1536.jpg 2048w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-150x113.jpg 150w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173542-200x150.jpg 200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The Raspberry Pi is mounted with the help of what I built <a href=\"https:\/\/andyland.info\/wordpress\/?p=7594\">over here<\/a>. There is not too much space left but everything fits into the compartment if you just squeeze it firmly enough.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-1024x768.jpg\" alt=\"\" class=\"wp-image-7755\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-1024x768.jpg 1024w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-300x225.jpg 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-768x576.jpg 768w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-1536x1152.jpg 1536w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-2048x1536.jpg 2048w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-150x113.jpg 150w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201026_173613-200x150.jpg 200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When the device is powered on it connects to the internet, randomly selects one of the playlists and starts playing in shuffle-mode. Playlists are read from an xml-file which is stored on GitHub. This allows me to change the playlists from remote. The player reboots every night at 4 o&#8217;clock and automatically checks for updates. The Spotify-part is handled via <a href=\"https:\/\/tizonia.org\/\" data-type=\"URL\" data-id=\"https:\/\/tizonia.org\/\">Tizonia<\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The handling of the buttons, sanity checks, etc is done in a rather simple python-script. The script uses the D-Bus interface to connect to the Tizonia player. Based on the file &#8216;updateID&#8217;  (see repo) I can trigger an update of the script itself. Everything can be found in this <a href=\"https:\/\/github.com\/Andymann\/Tizonia-RPI3\">Github repo<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>[Update]<\/strong> In order for Tizonia to work without consuming ridiculous amounts of CPU it is necessary to autologon into an X-Window (configure that in raspi-config). If you want to run the system without the need for a monitor add the line <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">export DISPLAY=&#8221;:0&#8243;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">at the end of the file .bashrc. I figured out that things become somewhat sketchy when running interactively from the command line (DBUS not reacting, high amount of CPU usage, &#8230;). That&#8217;s why the script &#8216;tizonia.py&#8217; (see repo) starts a dedicated lxterminal in order to run Tizonia:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">subprocess.call(&#8216;lxterminal -e tizonia &#8211;spotify-playlist-id &#8216; + lst_playlist[playlistID] + &#8216; -s &amp;&#8217;, cwd=&#8217;\/home\/pi\/&#8217;, shell=True)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Please also enable the DBus interface in Tizonia&#8217;s config file: <strong>mpris-enabled = true<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong> [\/Update]<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-768x1024.jpg\" alt=\"\" class=\"wp-image-7757\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-768x1024.jpg 768w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-225x300.jpg 225w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-1152x1536.jpg 1152w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-1536x2048.jpg 1536w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-113x150.jpg 113w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/IMG_20201208_1123052-scaled.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I built a Spotify-Player based on a Raspberry Pi 3 and Tizonia. It has 5 buttons to switch between different playlists and another button to skip to the next song in a playlist.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[90,19,5,24],"tags":[58,434,433,420],"class_list":["post-7657","post","type-post","status-publish","format-standard","hentry","category-3d-printing","category-musik","category-projekte","category-raspberry-pi","tag-raspberry-pi-2","tag-spotify","tag-tizonia","tag-trash-osnabrueck","odd"],"_links":{"self":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/7657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/comments?post=7657"}],"version-history":[{"count":0,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/7657\/revisions"}],"wp:attachment":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/media?parent=7657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/categories?post=7657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/tags?post=7657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}