jcrossbdn / fpp-after-hours

After hours music player plugin for Falcon Pi Player
2 stars 3 forks source link

FPP After Hours Music Manager

This plugin allows you to configure music sources for playback typically outside of show hours

Known limitations / Gotchas

Getting Started

  1. Get sound working through fpp (ensure proper sound card is selected, go to Status/Control and then Status Page and click volume + and then volume - once (this ensures the volume is set to match fpp as there are sometimes inconsistencies)
  2. Install the plugin (you must be connected to the internet and have DNS properly configured to do this without errors)
    • from the fpp user interface, Content Setup / Plugin Manager, click on the install button beside the After Hours Music Player Plugin
  3. Navigate to the "Content Setup" menu in the Falcon Player User Interface and then the "After Hours Music" option. If you dont see this option then refresh your browser window.
  4. You will then be presented with the After Hours plugin home page.
  5. You will likely see only a screen that says "Additional Software Must Be Installed". Click the "Install" button to install Media Player Daemon (mpd) and a control interface called mpc. The after hours music plugin uses these applications to play music and are not optional. This installation can take a long time, don't leave your browser window until the page loading indicator has completed on your browser. If you refresh or close your browser window before it completes you will have to install the dependencies manually from the command line. The command is sudo apt update && sudo apt -y install mpd mpc

first page

  1. Once installation of mpd and mpc has completed you will be presented with a confirmation screen. Click "Click here to return to after hours plugin page".

first page confirm

After an OS Upgrade

You will have to reinstall all the dependencies, however, all your configurations should have been restored after the upgrade. This installation can take a long time, don't leave your browser window until the page loading indicator has completed on your browser. If you left the page early or clicked out of it you will have to install the dependencies manually from the command line.

Configuration files are located in /home/fpp/media/plugindata and will be backed up by fpp if you choose Backup Area "Plugin Settings" when doing an FPP Backup from the "Status/Control" menu.

Navigation

home page

This plugin is currently only setup to handle internet audio streams. Local music is on the roadmap but has not been completed yet.

The page is separated into a few sections

Adding a new Internet Radio Stream

  1. Click the Add Stream button just below the controls section. Enter the name or description you want in the Name field and add the URL of the stream in the URL field (see below for how to find the URL)
  2. Click Create

Testing an Internet Radio Stream

  1. To test a stream you must make it Active by checking off the Active checkbox beside the desired stream
  2. Then you can move the entry to the top of the list or make all other streams Inactive by unchecking their Active checkboxes
  3. If there is an error reaching the url an alert icon will appear above the streams name. This check does not ensure the url actually plays music, just that it is reachable.4. Click "Start" and the stream should start playing through the system.
  4. Use the Volume slider to adjust the current volume to the desired level. Once you have the volume you want you can enter it into the volume setting for that stream and it will be used on future plays.
  5. Click Stop to stop the stream. The systems volume will be automatically reverted to the "show volume" (the volume that the fpp was at before running the Start Script).

Internet Radio Station selection order and priority

  1. The Start Script will first look at all saved radio stations you have
  2. It will then determine which ones are in an active state
  3. It will then ping the server to see if it is online
  4. It will then look at the order you have them in on the user interface
  5. The first available stream will be started
  6. The current volume will be saved as "Show Volume" and the fpp volume will be adjusted if you have a value in the volume column for that station.

How does volume work

Finding the URL of your favorite internet radio station

There are several internet radio streams available and you just have to find something that can be played by the "mpc" player. I have found that some .m3u links don't work but most .pls streams seem to (I have not explored why).

https://www.internet-radio.com/stations/christmas/# is one site where you can find many stations. Navigate to this website, find the station you would like and click on the ".pls" link. Save the file or open with notepad or another text editor.

Here is a sample .pls file
[playlist]
NumberOfEntries=1
File1=http://192.111.140.11:8576/listen.pls?sid=1

copy the http://192.111.140.11:8567 (ignore the ending slash and text) and that is your stream URL that you can paste into the after hours plugin page.

Using this plugin in conjunction with your show playlist

Once the plugin is configured you will see there are two commands presented as "FPP Commands" in the playlist editor called "FPP After Hours Plugin - Start" and "FPP After Hours Plugin - Stop". If you don't see these Commands then you must either reboot the computer or restart FPPD.

  1. To start and stop the after hours radio station go to the desired playlist (Content Setup / Playlists / click the desired playlist).
  2. You can then click "Add a Sequence/Entry"
    • Choose type: FPP Command
    • Choose Command: FPP After Hours Plugin - Start
      • If you want the plugin to fade in the music enter the number of seconds you want the fade to happen over (or 0 to not fade)
      • If you want to fade you can also set the starting volume of the fade as most audio you cant hear until 30-50 percent.
    • Click "Add"
  3. Click "Add a Sequence/Entry" again
    • Choose type: FPP Command
    • Choose Command: FPP After Hours Plugin - Stop
      • If you want the plugin to fade out the music enter the number of seconds you want the fade to happen over (or 0 to not fade)
      • If you want to fade you can also set the ending volume of the fade as most audio you cant hear below 30-50 percent.
    • Click "Add"
  4. **It is highly recommended that you also add a type: Pause for 1 second (failure to do so could cause your show to not start properly especially if using a USB sound card)
  5. Drag and drop the "FPP After Hours Plugin - Stop" command into the "Lead In" section
  6. Drag and drop the PAUSE right under the "FPP After Hours Plugin- Stop" command IMPORTANT
  7. Drag and drop the "FPP After Hours Plugin - Start" command into the "Lead Out" section
  8. Click Save Playlist
  9. The after hours radio station will now start when your show ends and stop when your show is about to start

sample playlist

Why do I need a pause if using a USB sound card

With the USB sound card I have tested only one program can use the sound card at the same time. This pause ensures that the stop script has enough time to actually stop playing before fpp tries to start your playlist. If fpp tries to play music before after-hours has released fpp will error out and wait. It is best practice with this plugin to add a 1 second pause all the time.

Q & A

Q- I switched fpp to use a different sound card. Do I need to change anything in this plugin?

A- The plugin will automatically detect new sound cards and configure mpd to use the same one as fpp. It is recommended that you press the volume up and then volume down once on the fpp Status Page Screen to ensure the volume is set properly on the new card. When a sound card is added or removed the plugin will take a few seconds to make necessary configuration changes and restart the mpd daemon when the start script is run (either through a playlist or by clicking Run Start Script. Subsequent start script runs should be instant.

Technical

API

All fpp-after-hours functions from the user interface are now handled by the fpp-after-hours API which is exposed on the computer running the fpp-after-hours plugin. The API endpoints are as follows:


Get stream and fpp-after-hours current details

GET /api/plugin/fpp-after-hours/getDetails[?titleOnly]


Get Streams

GET /api/plugin/fpp-after-hours/getStreams[?noPing]


Get Stream Availability

Tests the url for successful connection. Does not actually make sure the endpoint is a valid stream

GET /api/plugin/fpp-after-hours/getStreamPing?uid


Start the first available stream

GET /api/plugin/fpp-after-hours/start


Stop the currently playing stream

GET /api/plugin/fpp-after-hours/stop


Set MPD Volume

Will only change the volume of the MPD player and only works when MPD is playing (fpp-after-hours is in control of the audio)

GET /api/plugin/fpp-after-hours/setMPDvolume?value


Update Stream

POST /api/plugin/fpp-after-hours/updateStream


Delete Stream

GET /api/plugin/fpp-after-hours/deleteStream?deleteStream=<uid of stream>


Update Scripts

Will check all scripts and crontab entries and update them if there are any changes

GET /api/plugin/fpp-after-hours/updateScripts


Install Dependencies

Will run the linux command "sudo apt update && sudo apt -y install mpd mpc"

GET /api/plugin/fpp-after-hours/installDependencies[?stream]