PHP Classes
elePHPant
Icontem

Unified PHP Playlist: Read playlists of formats asx, m3u, pls, xspf, etc

Recommend this page to a friend!
  Info   View files Example   View files View files (18)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-03-23 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 91 This week: 47All time: 8,713 This week: 14Up
Version License PHP version Categories
unified-playlist 1.0.0MIT/X Consortium ...5.3PHP 5, Files and Folders, Audio, Parsers
Description Author

This class can read playlists of formats aimppl, asx, xspf, zpl, m3u, pls, and upf.

It can take a given play list file and parse it to extract the metadata of the playlist it self and the tracks it contains.

For the playlist it extracts the title, the total track count, duration and file size.

For each track it extracts the URL, artist, song, album, genre, year, bitrate, sample rate, and duration.

Innovation Award
PHP Programming Innovation award nominee
April 2017
Nominee
Vote
Playlists are lists of audio and video clips that can be watched in a sequence defined by the user. Playlists can be saved in files defined in many different formats.

This class can read playlists in many well known formats. It can extract many types of details of the listed media.

Manuel Lemos
  Performance   Level  
Name: Sergey Vanyushin is available for providing paid consulting. Contact Sergey Vanyushin .
Classes: 13 packages by
Country: Russian Federation Russian Federation
Age: 21
All time rank: 85331 in Russian Federation Russian Federation
Week rank: 10 Up1 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 13x

Winner: 1x

Details

UnifiedPlaylist

Composer package

A Unified Reader of playlist formats. Supports all popular playlist file formats and all their features.

Format | Parsing | Creation --------|---------|--------- aimppl | + | - asx | + | - xpl | - | - xspf | + | - zpl | + | - m3u | + | - pls | + | - upf | + | -

Usage

Firsly, check that file looks like a playlist. Then, try to open it with open() static method. In case of success it will return an instance of UnifiedPlaylist with all needed information.

use wapmorgan\UnifiedPlaylist\UnifiedPlaylist;

if (UnifiedPlaylist::isPlaylist($tmpfile)) {
    $playlist = UnifiedPlaylist::open($tmpfile);
    /// ... operations here
}

Available operations:

  1. Traversing all tracks

    `php foreach ($playlist as $track) { echo $track->artist . ' - ' . $track->song.PHP_EOL.' ('.$track->formatDuration().')'; } `

    All available properties (real information can be missed due to format limitations or generator configuration):

    Property | Type -------------|---------- $url | string $artist | string $song | string $album | string $genre | string $year | int $bitrate | int $samplerate| int $duration | int

    Additional methods:

    Method | Description -----------------------------------|---------------------------------------------------------------------------------------------- formatDuration($format = 'auto') | Formats tracks duration as m:s, h:m:s or h:m. If auto, the best format will be used. isStream() | Checks if track is a network stream

  2. Retrieving information about playlist title, total duration or size of playlist

    `php echo 'Title: '.$playlist->getTitle().PHP_EOL; echo 'Total playlist duration: '.$playlist->formatTotalDuration().PHP_EOL; echo 'Total playlist size: '.$playlist->getTotalSize().PHP_EOL; `

  Files folder image Files  
File Role Description
Files folder imagebin (1 file)
Files folder imagesrc (6 files, 1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Documentation

  Files folder image Files  /  bin  
File Role Description
  Plain text file playlist Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageFormats (8 files)
  Plain text file ConfigurationException.php Class Class source
  Plain text file Exception.php Class Class source
  Plain text file FormatRestrictionException.php Class Class source
  Plain text file Track.php Class Class source
  Plain text file UnifiedPlaylist.php Class Class source
  Plain text file UnknownFormatException.php Class Class source

  Files folder image Files  /  src  /  Formats  
File Role Description
  Plain text file AdvancedStreamRedirector.php Class Class source
  Plain text file Aimppl.php Class Class source
  Plain text file BasicFormat.php Class Class source
  Plain text file M3u.php Class Class source
  Plain text file Pls.php Class Class source
  Plain text file UniversalPlaylist.php Class Class source
  Plain text file XmlShareablePlaylist.php Class Class source
  Plain text file ZunePlaylist.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:91
This week:47
All time:8,713
This week:14Up