樹莓派打造 Airplay 音樂


基礎: 音量調整

一、先用amixer cget指令取出可條最大值(每台機器都不同)
amixer cget numid=1


二、再根據最大數值最小數值調整音量
amixer cset numid=1  400







步驟:

開始安裝AirPlay服務,這裡我們全部基於一個GitHub的開源項目進行操作
項目主頁:github.com/juhovh/shair


sudo apt-get install autoconf automake libtool
sudo apt-get install libltdl-dev libao-dev libavahi-compat-libdnssd-dev
sudo apt-get install avahi-daemon


git clone https://github.com/juhovh/shairplay.git

動作三、 執行編譯和安裝
./autogen.sh
./configure
make
sudo make install 
 動作四、將3.5mm Jackpot設置為音頻輸出與音量條最大,去除雜音 
 
amixer cset numid=3 1amixer cset numid=1  400

sudo nano /boot/config.txt
然後在最末行增加
dtparam=audio=on
audio_pwm_mode=2 



shairplay -a RaspberryMusic
 然後用iOS產品測試看看能不能找到裝置
 

動作六、設置開機自動Shairplay

依次執行如下命令,建立一個啟動腳本文件。
cd /etc/init.d/
touch shairplay
nano shairplay
複製一下內容
#!/bin/bash
#
# This starts and stops shairplay
#
### BEGIN INIT INFO
# Provides: shairplay
# Required-Start: $network
# Required-Stop:
# Short-Description: Free portable AirPlay server implementation similar to ShairPort.
# Description: Free portable AirPlay server implementation similar to ShairPort.
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Source function library.
. /lib/lsb/init-functions

DAEMON="/usr/local/bin/shairplay"
DAEMON_ARGS="-a RaspberryMusic"
AIRPORT_KEY_DIR="/usr/local/share/shairplay"

[ -x $binary ] || exit 0

RETVAL=0

start() {
 echo -n "Starting shairplay: "
 start-stop-daemon --start --quiet --chdir $AIRPORT_KEY_DIR \
 --exec "$DAEMON" -b --oknodo -- $DAEMON_ARGS
 log_end_msg $?
}

stop() {
 echo -n "Shutting down shairplay: "
 start-stop-daemon --stop --quiet --exec "$DAEMON" \
 --retry 1 --oknodo
 log_end_msg $?
}

restart() {
 stop
 sleep 1
 start
}

case "$1" in
 start)
 start
 ;;
 stop)
 stop
 ;;
 status)
 status shairplay
 ;;
 restart)
 restart
 ;;
 *)
 echo "Usage: $0 {start|stop|status|restart}"
 ;;
esac
exit 0
 通過CTRL+O 保存更改, CTRL+X退出編輯器。
加入執行權限
依次執行如下命令。賦予腳本執行權限,並且更新配置信息。


chmod +x /etc/init.d/shairplay
update-rc.d shairplay defaults
 執行如下命令,切換到用戶目錄


cd ~
 依次執行如下命令,拷貝airport.key
mkdir /usr/local/share/shairplay
cp shairplay/airport.key /usr/local/share/shairplay
 在etc/rc.local中添加內容
 
 nano /etc/rc.local
在 exit 0之前 加入這行
/etc/init.d/shairplay start










0 意見:

張貼留言

LinkWithin

Related Posts with Thumbnails
top