PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Michael Kamleitner   AudioFile   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: script to test the class
Class: AudioFile
Extracts attributes of audio-files & Visualization
Author: By
Last change: - division by zero-error, which occured on some mp3s fixed, however, vbr isn't still supported!
- chris snyder's support for ogg-vorbis and id3v2-tags added!
- chris snyder's patch of the visualization-function added!
- applied the GPL (general public license)!
Date: 20 years ago
Size: 3,024 bytes
 

Contents

Class file image Download
<?php

// ************************************************************************
// Program: test.php
// Version: 0.5.1
// Date: 17/04/2003
// Author: michael kamleitner (mika@ssw.co.at)
// WWW: http://www.entropy.at/forum.php?action=thread&t_id=15
// (suggestions, bug-reports & general shouts are welcome)
// Desc: this test-script lists all audio-files (.wav, .aif, .mp3, .ogg)
// which reside in the ./ directory. If a file is selected,
// it is loaded and its audio-attributes are displayed.
// Copyright: copyright 2003 michael kamleitner
//
// This file is part of classAudioFile.
//
// classAudioFile is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// classAudioFile is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with classAudioFile; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// ************************************************************************
   
   
require ('classAudioFile.php');

    print
"<html><head>";
    print
"<link rel=\"stylesheet\" type=\"text/css\" href=\"./global.css\">";
       print
"<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
    print
"<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">";
    print
"</head><body>";

    print
"<table border=1>";
    print
"<tr><td valign=top>";
   
   
$handle=opendir('./');
    while (
false !== ($file = readdir($handle)))
    {
            if (
$file <> "." && $file <> "..")
            {
                if ( (
substr(strtoupper($file),strlen($file)-4,4)==".WAV") ||
                     (
substr(strtoupper($file),strlen($file)-4,4)==".AIF") ||
                     (
substr(strtoupper($file),strlen($file)-4,4)==".OGG") ||
                     (
substr(strtoupper($file),strlen($file)-4,4)==".MP3") )
                {
                         print
"<a href=\"./test.php?filename=$file\">$file</a><br>";
                } else {
                }
            }
    }
   
    print
"</td><td valign=top>";
   
    if (
$HTTP_GET_VARS[filename] <> "")
    {
       
$AF = new AudioFile;
       
$AF->loadFile($HTTP_GET_VARS[filename]);
       
$AF->printSampleInfo();
        if (
$AF->wave_id == "RIFF")
        {
           
$AF->visual_width=600;
           
$AF->visual_height=500;
           
$AF->getVisualization(substr($HTTP_GET_VARS[filename],0,strlen($HTTP_GET_VARS[filename])-4).".png");
            print
"<img src=./".substr($HTTP_GET_VARS[filename],0,strlen($HTTP_GET_VARS[filename])-4).".png>";
        }
    }
    print
"</td></tr></table></body></html>";
?>