This shows you the differences between two versions of the page.
|
tutorials:cb1:customization:wireless_music_box [2013/11/23 20:00] soloforce [LIRC Configuration] |
tutorials:cb1:customization:wireless_music_box [2013/12/23 14:50] (current) |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| ===== Abstract ===== | ===== Abstract ===== | ||
| - | Cubieboard series have support for infra-read (IR) support and analog sound ouput. Together with mplayer, Cubieboard could be turned into a great music box. | + | Cubieboard series have support for infra-red (IR) support and analog sound ouput. Together with mplayer & LIRC, Cubieboard could be turned into a great music box. |
| ===== Prerequisite ===== | ===== Prerequisite ===== | ||
| * A Cubieboard (1,2,3 are ok, theoretically) | * A Cubieboard (1,2,3 are ok, theoretically) | ||
| Line 43: | Line 43: | ||
| 0000070 c0d7 528c 273e 0004 0000 0000 0000 0000 | 0000070 c0d7 528c 273e 0004 0000 0000 0000 0000 | ||
| </code> | </code> | ||
| - | Pay attention to digits such as "0009", "0015", yes, they are the remote keycode, and you'd better write them down. | + | Pay attention to digits such as "0009", "0015", yes, they are the remote keycode, and you'd better write them down. Take notice that these keycodes are hexadecimal value. |
| ===== Software Installation ===== | ===== Software Installation ===== | ||
| <code> | <code> | ||
| Line 69: | Line 69: | ||
| </file> | </file> | ||
| ==== LIRC keycode table ==== | ==== LIRC keycode table ==== | ||
| - | Edit //**/etc/lirc/lircd.conf**// in your case. The **codes** section should be altered according to your own keycodes definitions. | + | Edit //**/etc/lirc/lircd.conf**// in your case. The **codes** section should be altered according to your own keycodes definitions, and they are in decimal form. |
| <file> | <file> | ||
| begin remote | begin remote | ||
| Line 122: | Line 122: | ||
| end remote | end remote | ||
| </file> | </file> | ||
| + | The above keycode definitions are for the IR remote like this | ||
| + | |||
| + | {{:tutorials:cb1:customization:2013-11-23-202655_433x296_scrot.png?400 |}} | ||
| ==== LIRC control file ==== | ==== LIRC control file ==== | ||
| Edit //**/etc/lirc/lircrc.conf**// in your case. | Edit //**/etc/lirc/lircrc.conf**// in your case. | ||
| Line 185: | Line 188: | ||
| ===== Player Program ===== | ===== Player Program ===== | ||
| + | Mplayer has well support for LIRC, but we still need do some work to make it functional like a music box. We intend to make mplayer scan some specified directory (on Cubieboard or network-sharing directory), picking out those supported music files, like ape, flac, mp3, ogg etc., and play them in a shuffle way. Here goes the shell code snippet. | ||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | # start_mplayer.sh | ||
| + | # Set this line in your case. A play.list file will be created in this directory, so make it writable. | ||
| + | MUSIC_PATH="/data/share/music" | ||
| + | PLAY_LIST="play.list" | ||
| + | MUSIC_TYPES="mp3 wav ape ogg flac"; | ||
| + | |||
| + | if [ ! -e "${MUSIC_PATH}/${PLAY_LIST}" ] || ( [ $# -gt 0 ] && [ $1 == "rescan" ] ); then | ||
| + | echo "" > ${MUSIC_PATH}/${PLAY_LIST} | ||
| + | for music_type in $MUSIC_TYPES ; do | ||
| + | find ${MUSIC_PATH} -type f -iname "*.${music_type}" >> ${MUSIC_PATH}/${PLAY_LIST} | ||
| + | done | ||
| + | fi | ||
| + | |||
| + | mplayer -lircconf /etc/lirc/lircrc.conf -vo null -shuffle -playlist ${MUSIC_PATH}/${PLAY_LIST} | ||
| + | </code> | ||
| + | Assign this script with an executable bit, and test it. | ||
| + | # chmod +x start_mplayer.sh | ||
| + | # ./start_mplayer.sh rescan | ||
| + | If mplayer is starting playing the music, good to go. | ||
| + | |||
| + | ===== Run LIRC with mplayer ===== | ||
| + | You can test LIRC with mplayer right now, with //**irexec**//, a convenient tool for running programs via LIRC. | ||
| + | # irexec -d /etc/lirc/lircrc.conf | ||
| + | Now, press your IR remote key, enjoy the music comes from Cubieboard. | ||
| + | |||
| + | If you would like the program running in a daemon style, add the fowlling line into //**/etc/rc.local**//, right before "exit 0". | ||
| + | <file> | ||
| + | sudo /usr/bin/irexec -d /etc/lirc/lircrc.conf | ||
| + | ## If there is no "sudo", irexec won't work, which is weird. | ||
| + | </file> | ||
| <WRAP noprint> | <WRAP noprint> | ||
| {{tag>Cubieboard Cubieboard2 IR remote music}} | {{tag>Cubieboard Cubieboard2 IR remote music}} | ||
| </WRAP> | </WRAP> | ||