Location: PHPKode > scripts > Play List Importer > mediaimporter.class.php
<?php
	//==============================================================//
	// Media Importer script					//
	//	by Kalle S. Nielsen (C) ClanTemplates.com		//
	//==============================================================//
	class MediaImporter
	{
		// Array builder function
		function build($file, $player)
		{
			// Return Array
			$return = Array();
			
			// Select player driver
			switch($player)
			{
				// If windows Media Player
				case('mediaplayer'):
					$stream = simpleXML_load_file($file);

					// Set title
					$return['title'] = $stream->head->title;

					// Meta tags
					foreach($stream->head->meta as $meta)
					{
						$name = strtolower($meta['name']);

						switch($name)
						{
							// Parse Generator tag
							case('generator'):
								$xp = explode('--', $meta['content']);
								$xp[1] = str_replace(' ', '', $xp[1]);

								$return[$name] = Array();
								$return[$name]['program'] = $xp[0];
								$return[$name]['version'] = $xp[1];
							break;

							// Item counter
							case('itemcount'):
								$counts = 0;

								foreach($stream->body->seq->media as $tt)
								{
									++$counts;
								}

								$return['itemcount'] = Array();
								$return['itemcount']['original'] = $meta['content'];
								$return['itemcount']['total'] = $counts;
							break;

							// Default
							default:
								$return[$name] = $meta['content'];
							break;
						}
					}

					// Body tags
					$return['body'] = Array();
					$counts = 0;

					foreach($stream->body->seq->media as $tt)
					{
						$return['body'][$counts]['path'] = $tt['src'];

						++$counts;
					}

					return($return);
				break;

				// Else if unsupported
				default:
					die('<br /> <br /> <b>Warning:</b> Player is not supported!');

					return(false);
				break;
			}
		}
	}

	// Constants
	define('MEDIA_WMP', 'mediaplayer');		// Windows Media Player
?>
Return current item: Play List Importer