YJ Park's profileYJParkPhotosBlogListsMore Tools Help

Blog


    9/21/2006

    Use Mpd to Stream Music as Internet Radio

    Mpd can work with icecast for streaming music, but the current statble version doesn't include this feature yet, so you have to check out the latest code from svn, here are the commands I used to build it.

    sudo apt-get install icecast2
    sudo apt-get install autoconf automake1.9 libtool make
    sudo apt-get install libshout3-dev liblame-dev libmad0-dev libao-dev libflac-dev libasound2-dev
    svn co https://svn.musicpd.org/mpd/trunk mpd
    cd mpd
    ./autogen.sh
    ./configure
    #make sure the shout is enable
    make
    sudo make install

    Or if you are lazy can download the binary I built, but make sure to install the needed libs

    wget http://yjpark.googlepages.com/mpd
    sudo mv mpd /usr/bin

    In your mpd configuration (/etc/mpd.conf or ~/.mpdconf), add these lines

    audio_output {
            type              "alsa"
            name              "local playback"
    }

    ################# SHOUT STREAMING ########################
    #
    # Set this to allow mpd to stream its output to icecast2
    # (i.e. mpd is a icecast2 source)
    #
    audio_output {
            type              "shout"
            name              "yjpark's stream"
            host              "localhost"
            port              "8000"
            mount             "/yjpark"
            password          "******"
            quality           "10.0"  
    #       bitrate           "64"
            format            "44100:16:2"

    # Optional Paramters
            user            "source"
    #       description     "here's my long description"
    #       genre           "jazz"
    } # end of audio_output
    ##########################################################

    If you don't want to hear the music from the computer's local speaker, can remove the first audio_output section.

    You need to change the name and mount point and password, and can change the quality or bitrate and format if you want, for more detail please check icecast2's documents.

    And you need to edit /etc/icecast2/icecast.xml, the only things I changed are source-password(same as the one in mpd configuration), and admin-user, admin-password(can use this to admin through web interface)

    then restart icecast2 and mpd, play some songs, then you can use a browser to connect to http://localhost:8000, you should see the source played by mpd, then can listen to it using an radio player(amarok, rhythembox, xmms...)

    For the guys in ExoWeb, you can listen to the same songs I am listenning with http://yjpark:8000/yjpark.m3u (Hope this will not slow down my machine too bad :) )

    Links:

        * http://my.opera.com/chongmeng/blog/show.dml/362421
        * http://mpd.wikia.com/wiki/Configuration
        * http://etnoy.broach.se/2006/06/your-own-internet-radio-station-with-mpdicecast.html

    Fix on ncmpc to make chinese display working

    Ncmpc is a command line mpd client, it's very good, but the chinese support has some problem, in the song list window, chinese names are truncated.

    At first I thought might be some unicode bug in it, after read some source code, here is what I found: it deal with unicode correctly, the problem is it didn't consider the wide-charactors like chinese charactors, so in the list window, it just show the correct chinese charactors then erase some of them later. change two lines this is ok.

    the patch is

    Index: src/list_window.c
    ===================================================================
    --- src/list_window.c (revision 4813)
    +++ src/list_window.c (working copy)
    @@ -203,10 +203,10 @@
    if( show_cursor && selected )
    wattron(lw->w, A_REVERSE);

    + if( fill )
    + mvwhline(lw->w, i, 0, ' ', lw->cols);
    //waddnstr(lw->w, label, lw->cols);
    waddstr(lw->w, label);
    - if( fill && len<lw->cols )
    - mvwhline(lw->w, i, len, ' ', lw->cols-len);

    if( selected )
    wattroff(lw->w, A_REVERSE);

    Using the following commands, you can build ncmpc automatically.

    sudo apt-get install build-essential
    svn checkout https://svn.musicpd.org/ncmpc/trunk@4813 ncmpc
    cd ncmpc
    wget http://yjpark.googlepages.com/ncmpc_chinese_patch
    patch -p0 < ncmpc_chinese_patch
    ./autogen.sh
    ./configure --enable-artist-screen
    make
    sudo cp src/ncmpc /usr/bin/

    Or if you are lazy, can just download the binary I build and try it

    wget http://yjpark.googlepages.com/ncmpc
    sudo mv ncmpc /usr/bin/


    Can edit ~/.ncmpc/config to setup ncmpc, here is my settings

    auto-center = yes
    wide-cursor = yes
    enable-colors = yes

    set-xterm-title = yes
    xterm-title-format = "[[%artist% - ]%title%]|[%file%]"


    And if you want to run ncmpc in real console(not gnome-terminal or xterm), you can use zhcon(just apt-get), I cannot run zhcon with fb driver, here is how I start it

    zhcon --utf8 --drv=vga

    the --utf8 is needed for ncmpc to working correctly, and you can edit .zhconrc to change defaultencoding to GBK for better compatibility.

    It's still not perfectly running ncmpc in zhcon, especially there are some bad encoding strings in your songs' tags.

    Using mpd to play music

    Lately I moved to use mpd for my music playing, mpd is "Music Player Daemon", as its name says, it's a daemon to play music, not like amarok or rhythembox, it do not need X windows at all, so the music will not stop even if you restart X, this is one advantage of it, others includes multiple clients to control it, from command line tools, scriptable tool, web pages, X clients; very easy remote control; low resource requirement. And it's easy to stream as internet radio(will talk about this later in another post)

    mpd's website: http://www.musicpd.org/ there you can find kinds of clients for it, Personally I like ncmpc and pympd(not listed there) most, ncmpc base on ncurses lib, so console base, it's very easy to use with keyboard. pymod is a python client looks like rhythembox.

    To install mpd, under Debian or Ubuntu

    sudo apt-get install mpd

    ncmpc is in both Debian and Ubuntu too, but pympd is not avaliable to Ubuntu yet, you can install it by

    sudo apt-get install python2.4-profiler build-essential
    wget http://jaist.dl.sourceforge.net/sourceforge/pympd/pympd-0.07.tar.gz
    tar xzvf pympd-0.07.tar.gz
    cd pympd-0.07
    make
    sudo make install

    Ncmpc does not support chinese well, it support unicode, but for chinese like double byte, it will not show the song list correctly, some part is cutted, after some research in ncmpc source code, I finally resolve this problem. (Again, will talk about this in another post)
    9/15/2006

    Install Internet Explorer on Linux for Testing

    We need to test our site under Internet Explorer, to me this is the only reason I need to install vmplayer on my Debian machine, it works fine, but a little bit slow and complicate, the Wine project is used to provide windows api on linux, so it's possible to use it to run IE without a virtual machine, but the setup is not very easy for it, I did try once, didn't get it.

    Recently I know that there is an open source project for this, the name is ies4linux. It's objective is download IE's installer and setup wine then install it automatically for you, it works great, The only problem I met is the download process is not very reliable, I need to run it several times to get it installed successfully, so I include the files I downloaded, it only has IE6 in it, if you want to install other version, you need to download them by yourself.

    For the ExoMates with exosetup installed, you can do:

    exosetup import nordicbet
    cd /tmp
    sudo exosetup install nordicbet-ie

    If you do not have exosetup, you can just run the following scripts:

    apt-get install wine cabextract
    mkdir ~/.ies4linux
    cd ~/.ies4linux
    wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/downloads.tar.gz
    tar xzvf downloads.tar.gz
    rm downloads.tar.gz
    cd /tmp
    wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/ies4linux-2.0.3.tar.gz
    tar xzvf ies4linux-2.0.3.tar.gz
    cd ies4linux-2.0.3
    ./ies4linux

    ies4linux: http://www.tatanka.com.br/ies4linux/index-en.html