Skip to content

Install Raspberry Pi

PeteManchester edited this page Jun 28, 2020 · 29 revisions

To install MediaPlayer.

Download the latest MediaPlayer.zip from https://github.com/PeteManchester/MediaPlayer/releases

Check if you have Java installed enter

java -version

If you don't already have Java installed you will need to Install Java.

Once you have Java installed you can start the installation.

Install either MPD or MPlayer, if you already know which player you are going to use you don't need to install both, just the one you want to use.

Install MPD

sudo apt-get install mpd

Or install MPlayer

sudo apt-get install mplayer

Extract the MediaPlayer.zip to the /home/pi/ directory (this should include the mediaplayer_lib directory)

Change directory to /home/pi/mediaplayer

cd /home/pi/mediaplayer

Make the run.sh executable

sudo chmod +x run.sh

To test run the mediaplayer

sudo /home/pi/mediaplayer/run.sh

Some people have experienced issue with ^M characters being present in the run.sh after copying on the raspi (seems to be when copying from a Mac). You can check by using vi (sorry!!), if they are present you need to edit them out. (All scripts should not contain any ^M characters now)

Or to clean a file of ^M characters use the following command:

sed -i 's/\r$//g' <filename>

Or you can create your own run.sh by using nano, enter the text:

#!/bin/sh

DIRNAME="$( dirname "" )"
cd "${DIRNAME}"
java -jar /home/pi/mediaplayer/mediaplayer.jar &
_wlanexist=$(ifconfig | grep wlan) || true
if [ "$_wlanexist" ]; then
	iwconfig wlan0 power off
fi
exit 0

Ian has supplied some scripts that configure mediaplayer as a service:

Edit the scripts in the mediaplayer/scripts folder.

In the mediaplayer.sh script put the correct path to your mediaplayer directory.

In the mediaplayer.init script edit the USER and GROUP

Some of the scripts now seem to have got ^M characters in them, to clean a file of ^M characters use the following commands:

sed -i 's/\r$//g' mediaplayer.init
sed -i 's/\r$//g' mediaplayer.sh

and then run the following commands:

sudo install -m 755 -T mediaplayer.init /etc/init.d/mediaplayer
sudo install -m 755 -T mediaplayer.sh /usr/local/bin/mediaplayer
sudo insserv mediaplayer

Once the service is installed mediplayer will be started when the raspberry pi boots up. You can also run the following commands

sudo service mediaplayer status/start/stop/restart

If for any reason you need to remove the mediaplayer service, use the following command

insserv -r mediaplayer

For those who are using only a Wifi connection you might need to disable the Power Management of your Wifi Adapter. If you run iwconfig

`iwconfig'

You can see if Power Management is enabled:

pi@rpistudy ~ $ iwconfig
wlan0     IEEE 802.11bgn  ESSID:"*******"
          Mode:Managed  Frequency:2.437 GHz  Access Point: 60:A4:4C:D2:00:C8
          Bit Rate=65 Mb/s   Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=41/70  Signal level=-69 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:101  Invalid misc:965   Missed beacon:0

lo        no wireless extensions.

eth0      no wireless extensions.

If it is enabled you might need to disable it by editing the rc.local file:

sudo nano /etc/rc.local

And add the lines:

_wlanexist=$(ifconfig | grep wlan) || true
if [ "$_wlanexist" ]; then
	iwconfig wlan0 power off
fi

For example:

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
_wlanexist=$(ifconfig | grep wlan) || true
if [ "$_wlanexist" ]; then
	iwconfig wlan0 power off
fi

exit 0

If you are using a USB DAC on Wheezy or before you may need to edit the /etc/modprobe.d/alsa-base.conf to enable the USB DAC.

nano /etc/modprobe.d/alsa-base.conf

And comment out the line

options snd-usb-audio index=-2

so it will be

#options snd-usb-audio index=-2

If you are using a DAC on Jessie then you need to follow these instructions to make your USB SoundCard the default sound card:

http://raspberrypi.stackexchange.com/questions/40831/how-do-i-configure-my-sound-for-jasper-on-raspbian-jessie

First of all, check to see what order your cards have been loaded in:

$ cat /proc/asound/modules 0 snd_bcm2835 1 snd_usb_audio Counting cards begins from 0 so the default bcm2835 is loaded first and my USB card which has my mic is loaded second.

To reorder my cards, I first create a file named /etc/modprobe.d/alsa-base.conf. It can be named anything you want as long as it ends with .conf. I then added the following:

# This sets the index value of the cards but doesn't reorder.
options snd_usb_audio index=0
options snd_bcm2835 index=1
# Does the reordering.
options snd slots=snd_usb_audio,snd_bcm2835

The comments should explain what each line does. Once you do that, it seems you have to reboot your machine for it to work.

As of June 2020 the Alsa Device name seems to have changed from PCM to Headphone, so if not using a DAC with the Raspi to get the volume control to work edit the /etc/mpd.conf file to be like this:

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# An example of an ALSA output:
#
audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:0,0"        # optional
        mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
        mixer_control   "Headphone"     # optional
        mixer_index     "0"             # optional
}

If you are using an ArchLinux Raspi, please note, that you need to have the package binutils (we need the binary readelf) installed, to automatically detect the ABI (HardFloat or SoftFloat). Furthermore (on all platforms) you can link the corresponding lib directory to the default directory, e.g.

ln -s mediaplayer_lib/ohNet/linux/armv6hf/ mediaplayer_lib/ohNet/default

Currently we do provide the ohNet Libs for Win x86, Win x64, Linux i386, Linux x64, Linux Arm v5sf, Linux Arm v6sf, Linux Arm v6hf and Linux Arm v7.