PHP Classes

PHP Live Radio Streaming: Serve MP3 audio files to play from a playlist

Recommend this page to a friend!
  Info   Example   Demos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 1,362 All time: 2,854 This week: 42Up
Version License PHP version Categories
radio-streaming 2.2Free for non-comm...5.4HTML, PHP 5, Audio, AJAX
Description 

Author

This class can serve MP3 audio files to play from a playlist.

It can read a play list text file with the list of files of songs to play in MP3 format.

The class can read and serve the MP3 files for download and play on the browser side.

The class can also return information about the song currently being played.

On the browser side, each song may be played in an iframe while the information of the current song can be retrieved regularly using AJAX requests.

Picture of Rahman Haghparast
  Performance   Level  
Name: Rahman Haghparast <contact>
Classes: 10 packages by
Country: Iran Iran
Innovation award
Innovation award
Nominee: 2x

Example

<?php
/**
 * Created by PhpStorm.
 * User: Rahman
 * Date: 12/3/2015
 * Time: 1:21 PM
 */
require 'offlineradio.class.php';
$init = new stdClass();
$init->mp3Folder = dirname(__FILE__).DS.'files';
$init->playListName = 'list.txt';
$radio = new OfflineRadio($init);
$radio->playList();


Details

This class is written to enable offline radio making with php. My definition for offline radio is a set of recorded files that is played continuously after one another. It only supports mp3 files and works with modern browsers. Installation: unzip the downloaded file and make a folder in your webserver root directory. name it something like "radio". The index file is a simple html file that loads the player in an iframe and shows the name and duration of the file being played and the next one. You first need to add a folder to your radio folder and name it something like "files" and then execute generatelist.php in your browser to generate list.txt file to be used as the time table for your radio. The structure of list.txt is very simple. It is a comma seperated file. The first column is the path to the sound files and the second column is the time to broadcast it. I used new line (\r\n) to start a new row. The getPlayingItem() method in the class outputs which file needs to be played and the playList() method does the rest. It starts playing based on the time the viewers requested so every one who connects to your internet radio listens to the same thing. License: This program is free for non-commercial use. Please send any comments and questions to my email address: haghparast@gmail.com

  Boney M RadioExternal page  

Open in a separate window

  Files folder image Files (10)  
File Role Description
Plain text file class.mp3.php Class the mp3 class by mfboy (http://www.phpclasses.org/browse/file/26606.html)
Accessible without login Plain text file generatelist.php Example a script to generate the list of files to play from a folder. It calculates the duration of each file and calculates the playing time without any gaps in between
Accessible without login Plain text file generatelist24.php Example generate a playlist for 24 hours
Accessible without login Plain text file index.html Data showcase of how it works
Accessible without login Plain text file info.php Example generates an ajax output that shows the current playing file and the next one. It is used in index.html to show the playing item.
Accessible without login Plain text file jquery-2.1.4.js Data jquery to use for ajax calls in index.html
Accessible without login Plain text file list.txt Data sample time table list
Plain text file offlineradio.class.php Class the main class file
Accessible without login Plain text file playsong.php Example the file to start playing the mp3 files based on the time table
Accessible without login Plain text file readme.txt Doc. Read me first!

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,362
This week:0
All time:2,854
This week:42Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1175