2015年3月20日金曜日

Voyage MPD に ympd を入れる Installing ympd on a Voyage MPD running machine

追記あり! Further texts added. (01/25/2016, 02/15/2016, 11/05/2016, 07/07/2021)

Volumio や RuneAudio には秀逸な web UI があって,とくに mpd client がなくても一般的なブラウザからさまざまな操作ができる.一方,Voyage MPD の web UI は基本設定に関するものだけで,再生等のコントロールは完全に他のクライアント任せになっている.そのため mpd クライアントがインストールされていない端末からは操作ができない.

ympd というクライアントがある.これは一種の web サーバになっていて,ympd が動いているマシンにブラウザでアクセスする形で mpd をコントロールする.これを Voyage MPD の動いているマシンにインストールすると,ふつうのブラウザからでも再生制御ができるようになる.もちろん,ympd は Voyage とは別のマシンで動いていてもかまわないのだが,今回は Voyage の動いているマシン上で動作させる.ympd 自体は機能自体は最小限に抑えて,その分,軽いクライアントになっていて,Raspberry pi 用の mpd ディストリビューションのひとつ Archphile では標準インターフェースになっているようだ.

Although Volumio and RuneAudio include respective excellent web UIs for fully controlling the player funtions, the web UI of Voyage MPD works as an interface for basic settings only but does not control the music player functions.  ympd is a light-weight and web-based mpd client.  Although its client functions are limited and not very rich, when it runs on a Voyage MPD running machine, the fundamental player functions of the machine is controlled through the standard web browsers without further add-ins or so.  You don't need to install any mpd-client to your phones/tablets/PCs.


開発環境のインストール Installing developing environment
ympd は基本的にソースコードで配布されている (Arch Linux については 3rd パーティによるバイナリがあるようだが).なので,コンパイルする環境が必要である.
Voyage MPD は基本的に開発環境がちゃんと含まれていない.なので,最低限の環境を用意する.面倒なので作業はすべて root で.

ympd is distributed as the source code.  You have to build the working binary.  However, the standard Voyage MPD does not include the full development tools, and you have to prepare the essential environments to build.  Login as root.

とりあえず,基本のリフレッシュをかけておく.
First, refresh the fundamental system environments.

# remountrw
# apt-get update
# apt-get upgrade

最低限の環境を用意する.
Prepare the essential environments to build the ympd binary.

# apt-get install gcc
# apt-get install g++
# apt-get install make
# apt-get install cmake
# apt-get install git
# apt-get install doxygen

たぶんこのくらいでOKのはず (gcc くらいは入っていたかも).

libmpdclient のインストール Installing libmpdclient
ympd は libmpdclient (2.0以上) を必要とするので,まずそれをインストールする.
これもソースコード配布なので,ソースを取ってくる.git clone もできるはずだが,それだとなぜか configure が入っていないので,すなおに tar ボールを取ってきた.現時点での最新バージョンは 2.10.
ympd requires libmpdclient libraries.  Get the tar-ball.  The current version is 2.10.

# wget http://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.10.tar.gz
# tar xzf libmpdclient-2.10.tar.gz
# cd libmpdclient-2.10
# ./configure
# make
# make install
# cd ..

ympd のインストール Installing ympd
ympd は git でソースを取ってくる.ただし,SSL認証でエラーが出るので,セキュリティを無効にしてとりあえず突破.
The source codes of ympd are obtained using "git clone".  For ignoring the security problem (not recommended), I did:

# GIT_SSL_NO_VERIFY=true git clone https://github.com/notandy/ympd
# GIT_SSL_NO_VERIFY=true git clone https://github.com/SuperBFG7/ympd

https://github.com/notandy/ympd/archive/master.zip を落として展開するのでもいいかも.ただし,unzip も apt-get する必要あり.(最後の追記も読んで!)
Or you may get the zip package from https://github.com/notandy/ympd/archive/master.zip.  You have to install unzip (as "apt-get install unzip") to extract the package. (Note the additional text at the end of this post)

オリジナルの notandy/ympd からもダウンロードできるが,すでにメンテされておらず,現在は SuperBFG7 氏による fork が維持されているので,そちらを推奨.(2021年7月7日追記)
The original ympd by notandy is currently not maintained.  A fork by SuperBFG7 is being maintained and recommended. (Jul. 7, 2021)

ympd をビルド.
Build ympd.

# cd ympd
# mkdir -p build
# cd build
# cmake .. -DCMAKE_INSTALL_PREFIX=/usr
# make
# make install

これで,/usr/bin/ympd ができる.

テスト Test
動かしてみる.

# ympd

オプションを何も付けない場合,ympd はローカルマシンの 6600 番ポート (mpd のデフォルト) を叩く形で mpd を制御する.また,ympd の動いているマシンの 8080 番ポートが web UI のアクセス先になる.適当なブラウザから voyage.local:8080 にアクセスすると



こんな画面が出てくるはず.あとは適当にいじってみる.
Without command line options, ympd uses port 8080 for web UI and communicates with mpd daemon on the local machine through port 6600 (default for mpd).  Connect to "voyage.local:8080" from your browser.


自動起動の設定 Setting auto start-up
Voyage の場合は /etc/rc.local に以下を追記すればOK (例によって exit 0 の前に置くこと).

/usr/bin/ympd &

Add the above line to "/etc/rc.local".  It must be placed before "exit 0" line.



(追記)
2015年7月の時点での ympd はライブラリの中の曲を検出できない場合がある.この問題は開発サイトでも指摘されているが,2015/9/23時点でのスナップショットからのビルドでも解決していない. (おそらく mongoose のせいだと思うのだが,未検証)
15年3月時点でのスナップショットから build すると問題ない.ので,スナップショットを置いておく.
2016年1月25日に SuperBFG7 による修正が出された (多謝).原因は path に "," (カンマ) が含まれるときに展開できないというもの.src/mpc_client.c に修正が加えられた.これを入れて make したところ,問題は解決された.パッチ済みの全ソース (.tgzファイル) を こちら に置いておく.
2016年2月15日現在,上記の修正は正式に取り込まれた模様.上記のディスカッションスレッドは閉じられている.
2016年5月11時点でのスナップショットでは,opensslとlibssl-devをインストールしないと cmake が通らない.以下で対応.
# apt-get install openssl libssl-dev
2016年8月24日時点では,さらに pkg-config をインストールする必要がある.
# apt-get install pkg-config
2021年7月7日現在,オリジナルの notandy/ympd はすでにメンテされておらず,SuperBFG7氏による fork が維持されている.


(Additional text)
ympd at July 2015 does not work properly on handling of the library (probably caused by mongoose).  This issue has been reported at the developer's site but is not solved yet.
The binary built from the snapshot at May 2015 works well.  The snapshot is available here.
On Jan. 25, 2016, SuperBFG7 posted the fix:  src/mpc_client.c was fixed (great thanks!!!).  I did make ympd with this fix, then the binary works completely.  The fixed entire source codes (a gzipped tar ball) is available here.
On Feb. 15, 2016, the above contribution is included in the official source.  The discussion thread above was closed.
The snapshot at May 11, 2016 requires openssl and libssl-dev for passing the cmake operation.
# apt-get install openssl libssl-dev
The snapshot at Aug. 24, 2016 requires pkg-config for passing the cmake operation.
# apt-get install pkg-config
The original ympd by notandy is currently not maintained (checked on Jul. 7, 2021).  A fork by SuperBFG7 is being maintained (great thanks!).

3 件のコメント:

  1. libmpdclient のインストール Installing libmpdclient
    を行なって見たのですが、make でmakefile がないエラーでここから出来ませんでした。
    makefile をどのように設定すればできますか?
    VoyageMpdにYMPDをインストールするのにはとても意味があると思いますので宜しくお願い致します。

    返信削除
  2. コメントありがとうございます.
    doxygen のインストールを書き忘れていました.これがないと libmpdclient の configure ができなかったと思います.apt-get install doxygen を行ってから,もう一度,configure と make をやってみてください.

    返信削除
  3. yjoさん
    コメントありがとうございます。
    うまくインストール出来ました。動作もOKです。
    ありがとうございました。色々さわってみます。

    返信削除