{"id":166,"date":"2017-02-27T08:31:15","date_gmt":"2017-02-27T07:31:15","guid":{"rendered":"http:\/\/owncloud.gonscak.sk\/?p=166"},"modified":"2017-02-27T08:31:15","modified_gmt":"2017-02-27T07:31:15","slug":"how-to-create-a-raspberry-music-play-server","status":"publish","type":"post","link":"https:\/\/www.gonscak.sk\/?p=166","title":{"rendered":"How to create a raspberry music play server"},"content":{"rendered":"<p>One time, I must deal with sound on some area in specific time.<br \/>\nSo I created a raspberry based server, which runs, control&#8217;s and deal with radio stream. I used rpi1 &#8211; raspberry 1.<br \/>\nMaybe this can help someone.<br \/>\nFirts, we download Raspbian Jessie Lite and burn this image on sdhc card (of 2GB capacity at least):<\/p>\n<pre>wget https:\/\/downloads.raspberrypi.org\/raspbian_lite_latest\nunzip 2017-01-11-raspbian-jessie-lite.zip\ndd if=2017-01-11-raspbian-jessie-lite.img of=\/dev\/sdb bs=4M\n#make sure, that \/dev\/sdb is your sdhc card, free to format<\/pre>\n<p>After first use, make some enhacements and customizing:<\/p>\n<pre>sudo tune2fs -c 1 \/dev\/mmcblk0p2\n#this force to check sdhc card every reboot for errors<\/pre>\n<p>Edit \/ets\/fstab and force to use some log destination to ramdisk and with less write operations.<br \/>\nBecause after some time, the sdhc card may fail because of many writing operations on it. In my case, I deal with three bad shdc cards in two years.<br \/>\n&#8211; option noatime (Do\u00a0 not\u00a0 update\u00a0 inode\u00a0 access\u00a0 times on this filesystem)<\/p>\n<pre>\/etc\/fstab:\nnone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/log\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 size=1M,noatime\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 00\nnone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/tmp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 size=1M,noatime\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 00\nnone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/tmp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 size=1M,noatime\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 00<\/pre>\n<p>Next, I disabled swap, because I didn&#8217;t need it:<\/p>\n<pre>dphys-swapfile swapoff\ndphys-swapfile uninstall\nupdate-rc.d dphys-swapfile remove\n#check:\nfree -mh<\/pre>\n<p>And finally, install some software, create some scripts, to deal with the music itself.<\/p>\n<pre>#I prefer omxplayer\nsudo apt-get install omxplayer\nmkdir \/home\/pi\/stream<\/pre>\n<p>First script, that will be used in cron:<\/p>\n<pre>cat stream\/script_audio.sh\n#!\/bin\/bash\nif ps x |grep -v grep |grep -c \"omxplayer.bin\"\n\u00a0then\n\u00a0 echo \"everything is ok\"\n\u00a0else\n\u00a0\u00a0\u00a0 echo \"omxplayer missing, starting...\"\n\u00a0\u00a0\u00a0 sh \/home\/pi\/stream\/vlna.sh &amp;\nfi<\/pre>\n<p>This script starts to play our live radio.<\/p>\n<pre>cat stream\/vlna.sh\n#!\/bin\/bash\nomxplayer --vol -200 http:\/\/stream.radiovlna.sk\/vlna-hi.mp3 &amp;\nexit 0<\/pre>\n<p>And useful script to kill omxplayer from services and stop playing<\/p>\n<pre>cat stream\/kill_omx.sh\n#!\/bin\/bash\nomx=`ps ax |grep -v grep |grep \"omxplayer.bin\"\u00a0 | awk '{print $1}'`\nkill $omx\nexit 0<\/pre>\n<p>Every script must have execute permision:<\/p>\n<pre>chmod +x *.sh<\/pre>\n<p>And use crontab, for enable playing. This option runs script every minute every<br \/>\nday in week between 6 am. and 6pm. (from Monday to friday)<\/p>\n<pre>*\/1 6-18 * * 1-5 sh \/home\/pi\/stream\/script_audio.sh &amp;<\/pre>\n<p>So, if this will help to somebody, i will be happy \ud83d\ude42<br \/>\nHave a nice day.<br \/>\n@vasil<\/p>\n ","protected":false},"excerpt":{"rendered":"<p>One time, I must deal with sound on some area in specific time. So I created a raspberry based server, which runs, control&#8217;s and deal with radio stream. I used rpi1 &#8211; raspberry 1. Maybe this can help someone. Firts, we download Raspbian Jessie Lite and burn this image on sdhc card (of 2GB capacity &hellip; <a href=\"https:\/\/www.gonscak.sk\/?p=166\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to create a raspberry music play server<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[24,25,26,27],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-centos","tag-music","tag-omxplayex","tag-raspberry","tag-stream"],"_links":{"self":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=166"}],"version-history":[{"count":0,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}