IR Remote controlled MPD (Media Player Daemon) in Orange Pi Zero

Infrared remote control is always used for controlling TV and Media Devices and with an Orange Pi Zero in hand it doesn’t take much time to convert it in to an IR controlled Media player. Now to make a media player we need a suitable software which can work with Orange Pi Zero and support Infrared remote control. I chose MPD (Media Player Daemon) because the main application runs in the background and the front-end clients can run unblocked and independent.

Hardware:

To get started ,you will need to have  these set of  hardware. The links are part of my affiliate program.

Orange Pi Zero

https://www.banggood.com/Orange-Pi-Zero-H2-Quad-Core-Open-source-512MB-Development-Board-p-1110210.html?p=W214159476515201703B

Orange PI Zero Interface board

https://www.banggood.com/Orange-Pi-Zero-Expansion-Board-Interface-Board-Development-Board-p-1115982.html?p=W214159476515201703B

IR Remote

https://www.banggood.com/HX1838-Receiver-NEC-Code-Infrared-Remote-Control-Module-IR-Controller-p-937207.html?p=W214159476515201703B

Software:

Once you have the Orange Pi hardware, you need to setup ut getting a rootfilesystem, flashing it to the sd card, and after that you will need to configure the IR Remote control with Orange Pi Zero .

apt-get install mpd mpc
music_directory         "/var/lib/mpd/music"
playlist_directory              "/var/lib/mpd/playlists"
db_file                 "/var/lib/mpd/tag_cache"
log_file                        "/var/log/mpd/mpd.log"
pid_file                        "/run/mpd/pid"
sticker_file                   "/var/lib/mpd/sticker.sql"

user                            "root"
group                          "root"

bind_to_address         "localhost"

bind_to_address         "/run/mpd/socket"

input {
        plugin "curl"

}

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        mixer_type                      "software"
        device          "hw:0,0"        # optional
}

filesystem_charset              "UTF-8"
id3v1_encoding                  "UTF-8"

decoder {
plugin "mad"
enabled "no"
}

Here copy your audio files to the following path as defined by music_directory  “/var/lib/mpd/music” . Create a playlist of the files and put it on the as defined by playlist_directory  “/var/lib/mpd/playlists” . You can also put the radio station with .m3u extension here. For example, you can download your favourite station from here, https://www.internet-radio.com/ and copy to /var/lib/mpd/playlists.

/etc/asound.conf
pcm.!default {
type hw
card 0
device 0
}

ctl.!default {
type hw
card 0
}

Now everything should work fine, so lets restart the mpd.

/etc/init.d/mpd restart
or 
systemctl restart mpd.service

Now plug a Speaker or headphone to the 3.5 mm Audio out jack and in the command line type the following.

mpc ls - will list all the files and playlist
mpc add <playlist> will add a play list to the player
mpc update - will update the player database about the changes 
mpc play - will play
mpc next or mpc prev will navigate 
mpc volume +1 -increase the volume
mpc volume -2 -increase the volume

When the music plays and you are able to navigate then you are done with this part.

 

Code:

Now let us try to get the IR part to make it work with your remote control. As mentioned earlier setup your IR remote control with Orange pi  using this link. Copy the the following configuration to the path /etc/lirc/lircrc

begin
    prog = irexec
    button = KEY_NEXT
    config = mpc next
    repeat = 0
end
begin
    prog = irexec
    button = KEY_PREVIOUS
    config = mpc prev
    repeat = 0
end
begin
    prog = irexec
  button = KEY_PLAYPAUSE
  config = mpc play
end
begin
    prog = irexec
  button = KEY_EQUAL
  config = mpc pause
end
begin
    prog = irexec
  button = KEY_VOLUMEDOWN
  config = mpc volume -5
    repeat = 1
end
begin
    prog = irexec
  button = KEY_VOLUMEUP
  config = mpc volume +5
    repeat = 1
end

Here I have used VOL+ and VOL- keys to increase and decrease volume. PREV and NEXT button to navigate between songs back and forth. And finally used PLAY button to play and EQ button to pause. There are plenty of sophistication that can be brought to this system. If you have and comments or feedback or improvement please comment them below.

3 thoughts on “IR Remote controlled MPD (Media Player Daemon) in Orange Pi Zero

  • June 7, 2017 at 9:56 pm
    Permalink

    How use curl?

    **If you have an board like the Opi Lite/One, can use the external usb audio adapter like the CM108.
    Thanks by the post! help me a lot!!

    Reply
    • June 10, 2017 at 3:13 pm
      Permalink

      Thanks for your feedback. I havent used curl so far, I will update the post once I complete it.

      Reply
  • July 25, 2017 at 2:08 am
    Permalink

    and in Mopidy? It’s the same?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *