Now Playing Info

Please note that this script and plugin are currently in a testing phase. We are not responsible for any system crashes or website downtime that may occur as a result of using this software

Plugin Name: Now Playing Info

Description:

“Now Playing Info” is a versatile WordPress plugin designed to enhance online radio websites by displaying currently playing song information. Seamlessly integrating with SAM Broadcaster, this plugin utilizes a PAL script to fetch and update song metadata in real-time, ensuring your audience stays engaged with up-to-date track information.

Key Features:

  • SAM Broadcaster Integration: Utilize a custom PAL (Playlist Automation Language) script to connect directly with SAM Broadcaster, fetching live song data to display on your WordPress site. This feature is perfect for radio stations that require dynamic content synchronization between their broadcast software and their website.
  • Dynamic Content Display: The plugin allows the song information to auto-refresh at customizable intervals, ranging from 5 seconds to 120 seconds, to ensure your audience sees the latest tracks as they are played. PAL script updates titles only for songs that are 2 minutes in length or longer.
  • Customizable Display Options:
    • Header Customization: Add a custom header above the now playing information, such as “Now Playing,” to attract attention and fit the style of your site.
    • Inline Display: Choose to display artist and song title inline, making it a seamless part of your site’s content flow.
    • Label Control: Optionally show or hide the labels for “Artist” and “Title,” providing a cleaner and more customizable look to fit various design preferences.

Perfect For: Radio stations, DJs, and music enthusiasts who use WordPress to power their sites and wish to provide a real-time, interactive listening experience for their audience. This plugin bridges the gap between SAM Broadcaster’s powerful broadcasting capabilities and the accessibility and flexibility of WordPress.

PAL Script:



// Procedure to send song data
procedure SendSongData;
var
  httpClient : THttpClient;
  songInfo : TSongInfo;
  songData : string;
  url : string;
  songDuration : Integer; // Duration in milliseconds
begin
  songInfo := ActivePlayer.GetSongInfo;
  if songInfo <> nil then
  begin
    // Get the duration of the song and convert from milliseconds to minutes
    songDuration := songInfo['duration']; // Assuming 'duration' returns milliseconds

    // Check if song duration is at least 2 minutes (120,000 milliseconds)
    if songDuration >= 120000 then
    begin
      url := 'https://YOURSITE.com/wp-content/plugins/now-playing-info/post_song_details.php';
      httpClient := THttpClient.Create(url);

      try
        // Prepare and send the POST request
        songData := 'artist=' + URLEncode(songInfo['artist']) + '&title=' + URLEncode(songInfo['title']);
        httpClient.Post(songData, 'application/x-www-form-urlencoded');

        // Wait for the HTTP response
        while not httpClient.ResponseReady do
          Pal.WaitForTime('+00:00:01');

      finally
        httpClient.Free;
      end;
    end
    else
      WriteLn('Track is shorter than 2 minutes and will not be sent.');
  end
  else
    WriteLn('No track is currently loaded.');
end;

// Main entry point for the script
begin
  PAL.Loop := True; // Ensure the script runs continuously

  // Initially wait for one song to play
  PAL.WaitForPlayCount(1);

  while True do
  begin
    SendSongData; // Call SendSongData after a song has played
    PAL.WaitForPlayCount(1); // Wait for the next song to finish playing before running again
  end;
end;


Installation Instructions for “Now Playing Info” Plugin

Follow these steps to install and configure the “Now Playing Info” plugin to display live song information from SAM Broadcaster on your WordPress site.

Step 1: Download the Plugin

  1. Obtain the plugin zip file (now-playing-info.zip).

Step 2: Install the Plugin on WordPress

  1. Log in to your WordPress admin dashboard.
  2. Navigate to Plugins > Add New.
  3. Click the Upload Plugin button at the top of the page.
  4. Click Choose File and select the now-playing-info.zip file from your computer.
  5. Click Install Now to upload and install the plugin.
  6. Once the installation is complete, click Activate Plugin to activate “Now Playing Info” on your WordPress site.

Step 3: Configure the Plugin

  1. After activation, go to the newly added Now Playing menu in your WordPress admin dashboard.
  2. Configure the following settings:
    • Auto-refresh Interval: Set how often the plugin updates the now playing information, between 5 seconds (minimum) and 120 seconds (maximum).
    • Header Text: Enter a custom header that will appear above the now playing information, e.g., “Now Playing”.
    • Display Options:
      • Show Labels: Choose whether to display labels such as “Artist” and “Title”.
      • Display Inline: Check this option if you want the artist name and song title to be displayed on a single line.
  3. Save your changes.

Step 4: Implement the Shortcode

  1. To display the now playing information on your site, place theshortcode in the content of page, post, or widget where you want the song information to appear. Limitation: the shortcode can be rendered only once at a time.

Step 5: Configure the PAL Script in SAM Broadcaster

  1. Ensure SAM Broadcaster is set up to use the PAL script that interacts with the plugin. This script is responsible for sending the current song information to your WordPress site.
  2. Load the PAL script provided with the plugin into SAM Broadcaster.
  3. Start the script to begin transmitting song data to your WordPress site.

Step 6: Test the Setup

  1. Visit the page or post where you placed the shortcode to see the now playing information displayed.
  2. Check if the information updates at the interval you set and verifies that the display settings (header, inline, labels) are correct.

Troubleshooting

  • If the now playing information does not update, check your PAL script configuration in SAM Broadcaster and ensure it is running correctly.
  • Verify that the plugin settings in WordPress are configured correctly, particularly the URL or endpoint that the PAL script should target.
  • Ensure that your server’s firewall or security settings do not block outgoing data from SAM Broadcaster or incoming data to WordPress.