Location: PHPKode > scripts > HN Parse Playlist > hn-parse-playlist/hn_parseplaylist.documentation.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<TITLE>PHP-Class :: ParsePlaylist :: Documentation</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<style type="text/css">
<!--

/*********************************
 *
 *	globale HTML Styles
 *
 */
	a:link
	{
		color: #0079C5;
		background: transparent;
		text-decoration: none;
	}
	a:visited
	{
		color: #5DA3ED;
		background: transparent;
		text-decoration: none;
	}
	a:hover,
	a:active,
	a:focus
	{
		color: #cd3021;
		background: transparent;
		text-decoration: underline;
	}

	html,
	body
	{
		margin-top: 20px;
		margin-bottom: 20px;
		margin-left: 20px;
		margin-right: 20px;
		padding-top: 0px;
		padding-bottom: 0px;
		padding-left: 0px;
		padding-right: 0px;
	}

	body
	{
		background-color: #FFFFFF;
		color: #000000;
		font-family: Verdana, Helvetica, Arial, sans-serif;
	}

	h3
	{
		margin-left: 30px;
		margin-right: 10px;
		background: transparent;
		color: #222222;
		font-size: 18px;
		font-style: normal;
		font-weight: bold;
		font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
		line-height: 100%;
		letter-spacing: 1px;
	}

	h4 {
		margin-top: 20px;
		margin-left: 30px;
		margin-right: 5px;
		background: transparent;
		color: #000000;
		font-size: 14px;
		font-style: normal;
		font-weight: bold;
		font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
		line-height: 100%;
	}

	p {
		margin-left: 30px;
		margin-right: 20px;
		font-size: 12px;
		font-style: normal;
		font-weight: normal;
		font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
		background: transparent;
		color: #000000;
	}

	.box
	{
		margin-left: 30px;
		margin-right: 30px;
		margin-top: 20px;
		margin-bottom: 20px;
		border-style: dashed;
		border-width: 2px;
		border-color: #FFD940;
	}
	.phpclass
	{
		margin-left: 30px;
		margin-right: 20px;
		font-size: 14px;
		font-weight: bold;
	}
-->
</style>
</head>
<body>

<h3>PHP-Class :: HN ParsePlaylist :: Documentation</h3>
<p>Author:&nbsp;&nbsp;&nbsp;&nbsp;Horst Nogajski<br>
Licence:&nbsp;&nbsp;&nbsp;GNU GPL (http://www.opensource.org/licenses/gpl-license.html)<br>
Version:&nbsp;&nbsp;&nbsp;1.0&nbsp;&nbsp;&nbsp;(2005-01-06)</p>

<p class="phpclass">You can download the class at <a href="http://hn273.users.phpclasses.org/browse/package/2048.html">phpclasses.org</a>!</p>

<div class="box">
<h4>Parses Playlists (Audio)</h4>

<p>Current Version 1.0 supports reading/writing from/to:<br>
- extended m3u<br>
- pls version 2<br>
- simple m3u<br>
<br>
NOTE:<br>
If source is 'simple m3u', you only can save to simple m3u.<br>
If source is 'extended m3u' or 'pls',  you can save to any type.<br>
<br>
Optionally the class can sort the list, see methods.<br>
</p>
</div>

<div class="box">
<h4>Class "hn_ParsePlaylist"</h4>
<p><u>METHODS:</u></p>

<p>You can give a playlist to the class as file or string to parse it.<br>
NOTE: if you use parse_string-method, the string must contain line-endings!<br>
- <b>parse_file($filename)</b><br>
- <b>parse_string($s)</b>
</p>

<p>After parsing, we can retrieve an array with information of the playlist and the parse-process, calling the method:<br>
- <b>summary($asArray=FALSE)</b><br>
Without optional BOOLEAN argument all infos are displayed directly. This is meant for debugging.<br>
Passing TRUE to the method will return the infos as array.<br>
<br>
The following infos are available:<br>
 - <b>'file'</b> holds the filename of the parsed file, or an empty string when work with parse_string()<br>
 - <b>'valid'</b> is BOOLEAN TRUE if is a valid Playlist<br>
 - <b>'type'</b> can be: <b>extm3u</b>, <b>m3u</b>, <b>pls2</b><br>
 - <b>'count'</b> is the number of tracks in list<br>
 - <b>'errors'</b> best should be empty, ;-), but can contain warnings or error-messages if e.g. no valid playlist
</p>

<p>If it is a valid playlist, now all available track-infos are stored in internal array <b>$tracks</b>:<br>
 - <b>'title'</b> is the Tracktitle<br>
 - <b>'time'</b> holds the tracklength in seconds<br>
 - <b>'path'</b> contains the filepath or the stream-URL<br>
 - <b>'type'</b> contains 'file' if track is a file, and 'radio' if it beginns with 'http://'
</p>

<p>You can sort the internal playlist in hierarchic order of given <b>$sortlistArray</b>.<br>
<b>$sortlistArray</b> can be every combination of fieldnames: <b>'type','path','title','time'</b><br>
- <b>sortPlaylist($sortlistArray)</b>
</p>

<p>There are three methods to save the internal playlist to a file.<br>
- <b>saveAs_m3u($filename, $onlyType='')</b><br>
- <b>saveAs_simple_m3u($filename, $onlyType='')</b><br>
- <b>saveAs_pls($filename, $onlyType='')</b><br>
For all three methods you must specify a valid filename, which means: the script must have write-access to the directory/file and also you must take care to define the right filetype-extension, e.g. .m3u or .pls!<br>
There can be passed an optional second argument <b>$onlyType</b>. It's value can be 'radio' or 'file'. This is used to only include tracks of the desired type into the new playlistfile.
</p>

<p>Three other methods lets you retrieve the different plylist-types as string instead saving to a file.<br>
- <b>stringAs_m3u($onlyType='')</b><br>
- <b>stringAs_simple_m3u($onlyType='')</b><br>
- <b>stringAs_pls($onlyType='')</b><br>
Here we have only one optional argument <b>$onlyType</b>. It behaves like with the saveAs_-file-methods.
</p>
<p>&nbsp;</p>
</div>

</body>
</html>
Return current item: HN Parse Playlist