jailsonsb2 / Radioplayer_api

Single / multi-station radio player built with HTML, CSS, and JavaScript. This player dynamically fetches song information and offers the flexibility to use a local API or a pre-configured web-based API.
https://radio.jailson.es
3 stars 1 forks source link
html5 html5-audio html5player icecast icecast2 radio radioplayer shoutcast shoutcast-streaming zeno-radio

Single or Multi-Station Radio Player

This document provides a detailed guide on the structure, configuration, and customization of a single / multi-station radio player built with HTML, CSS, and JavaScript. This player dynamically fetches song information and offers the flexibility to use a local API or a pre-configured web-based API.

Demo Screenshots

Demo Screenshot

1. Overview

This radio player offers a user-friendly interface for enjoying online radio stations. It allows for the addition of multiple stations, each with its own live stream, song information, social media links, and more. Station configuration is done directly within the HTML, simplifying the customization process.

2. File Structure

3. Detailed Configuration

3.1. Configuring Stations (index.html)

Radio stations are configured within a <script> block in the index.html file, defining the window.streams.stations object. Each station is an object with the following properties:

Property Description
name Station name displayed on the interface.
hash Unique identifier for the station.
description Short description of the station.
logo Path to the station logo image file.
album Path to a default "album" image to display before the actual cover art is loaded.
cover Path to the currently playing song's cover art.
api (Optional) URL of the local API (api.php) configured to fetch station information. This should include the stream_url as a parameter. If left blank, the script will use the pre-configured web API within js/main.js.
stream_url URL of the station's audio stream.
tv_url URL of the station's live video stream (optional).
server Defines the music platform ("spotify" or "itunes") used to fetch additional info (if the corresponding API is in use).
program Object containing information about the current program (optional).
social Object with links to the station's social media profiles (optional).
apps Object with links to download the station's apps (optional).

Configuration Example:

<script>
window.streams = {
    timeRefresh: 10000, // Refresh time in milliseconds
    stations: [
        {
            name: "Example FM",
            hash: "examplefm",
            description: "The best music!",
            logo: "assets/examplefm_logo.png",
            album: "assets/default_album.jpg",
            cover: "assets/default_album.jpg",
            api: "api.php?url=https://example.com/stream", // Local API (optional)
            stream_url: "https://example.com/stream",
            server: "itunes", // Use iTunes API
            social: {
                facebook: "https://facebook.com/examplefm",
                instagram: "https://instagram.com/examplefm"
            }
        },
        // ... more stations
    ]
};
</script>

3.2. Local API (Optional)

If you choose to use the local API (api.php), follow these instructions to set it up:

Note:

If the api field is left blank in the station configuration, will default to the pre-configured web API. Make sure the web API you are using is functioning and correctly set up within the JavaScript code.

4. Customization, Interface, Interaction, and Publication

The sections regarding:

4.1. Key Elements

4.2. Navigation

5. Customization

5.1. Visual Styles (css/main.min.css and custom.css)

5.2. Images and Icons (assets/)

6. Publication

  1. Make sure the local API (api.php), if used, is configured correctly and accessible on your server.
  2. Upload all files and folders (HTML, CSS, JavaScript, PHP, images) to your web server.

Free Hosting

Deploy with Vercel Deploy to Netlify

7. Additional Considerations