List Info

Thread: to get the length or play-time/duration




to get the length or play-time/duration
user name
2006-12-14 09:39:11
Chithra,
I know ur Intention ...
plz use this one  , this is apt for ur requirements,
have a nice time,
Prasanth Nair
<?php 

//
************************************************************
************ 
// Class    AudioFile 
// Version: 0.4 
// Date:    24/04/2002 
// Author:  michael kamleitner (mikassw.co.at) 
//        reto gassmann (gassigassi.cx) - additional
mp3-code 
// WWW:        http://www.entropy.at/forum.php?action=thread&t_id=
15  
//          (suggestions, bug-reports & general shouts
are welcome) 
//
************************************************************
************ 

class AudioFile 
{ 
    var $wave_id; 
    var $wave_type; 
    var $wave_compression; 
    var $wave_channels; 
    var $wave_framerate; 
    var $wave_byterate; 
    var $wave_bits; 
    var $wave_size; 
    var $wave_filename; 
    var $wave_length; 
     
    var $id3_tag; 
    var $id3_title; 
    var $id3_artist; 
    var $id3_album; 
    var $id3_year; 
    var $id3_comment; 
    var $id3_genre; 
     
    var $visual_graph_color; 
    var $visual_background_color; 
    var $visual_grid_color; 
    var $visual_border_color; 
    var $visual_grid; 
    var $visual_border; 
    var $visual_width; 

    //
************************************************************
************ 
    // mp3info extracts the attributes of mp3-files 
    // (code contributed by reto gassmann (gassigassi.cx)

    //
************************************************************
************             
     
    function mp3info() 
    { 
        $byte             = array(); 
        $version         = array("MPEG Version
2.5",false,"MPEG Version 2 (ISO/IEC
13818-3)","MPEG Version 1 (ISO/IEC
11172-3)"); 
        $version_bitrate    = array(1,false,1,0); 
        $version_sampling    = array(2,false,1,0); 
        $layer            = array(false,"Layer
III","Layer II","Layer I"); 
        $layer_bitrate        = array(false,2,1,0); 
        $layer_lengt        = array(false,1,1,0); 
        $protection         = array("Protected by CRC
(16bit crc follows header)","Not protected");

        $byterate        = array( 
                        array( 
                           
array("free",32,64,96,128,160,192,224,256,288,320,
352,384,416,448,"bad"), 
                            array("free",32,48,56,
64, 80, 96,112,128,160,192,224,256,320,384,"bad"),

                            array("free",32,40,48,
56, 64, 80, 96,112,128,160,192,224,256,320,"bad") 
                             ), 
                        array( 
                            array("free",32,48,56,
64, 80, 96,112,128,144,160,176,192,224,256,"bad"),

                            array("free", 8,16,24,
32, 40, 48, 56, 64, 80, 96,112,128,144,160,"bad"),

                            array("free", 8,16,24,
32, 40, 48, 56, 64, 80, 96,112,128,144,160,"bad") 
                             ) 
                           ); 
        $samplingrate        = array( 
                        array(44100,48000,32000,false), 
                        array(22050,24000,16000,false), 
                        array(11025,12000, 8000,false) 
                           ); 
        $cannel_mode    =
array("Stereo","Joint stereo
(Stereo)","Dual channel
(Stereo)","Single channel (Mono)"); 
        $copyright    = array("Audio is not
copyrighted","Audio is copyrighted "); 
        $original    = array("Copy of original
media","Original media");  
        $emphasis    = array("none","50/15
ms",false,"CCIT J.17 "); 
     
    //id3-stuff 
     
    $genre            = array 
                    ("Blues","Classic
Rock","Country","Dance","Disco
","Funk","Grunge","Hip-Hop&quo
t;,"Jazz","Metal","New
Age","Oldies","Other","Pop&quo
t;,"R&B", 
                   
"Rap","Reggae","Rock","Te
chno","Industrial","Alternative",&q
uot;Ska","Death
Metal","Pranks","Soundtrack","
Euro-Techno","Ambient","Trip-Hop", 
                   
"Vocal","Jazz+Funk","Fusion",&
quot;Trance","Classical","Instrumental&q
uot;,"Acid","House","Game",&qu
ot;Sound
Clip","Gospel","Noise","Altern
ative Rock", 
                   
"Bass","Soul","Punk","Spa
ce","Meditative","Instrumental
Pop","Instrumental
Rock","Ethnic","Gothic","Darkw
ave","Techno-Industrial", 
                   
"Electronic","Pop-Folk","Eurodance&
quot;,"Dream","Southern
Rock","Comedy","Cult","Gangsta
","Top 40","Christian
Rap","Pop/Funk","Jungle", 
                    "Native
US","Cabaret","New
Wave","Psychadelic","Rave","Sh
owtunes","Trailer","Lo-Fi","Tr
ibal","Acid Punk","Acid
Jazz","Polka","Retro", 
                    "Musical","Rock &
Roll","Hard
Rock","Folk","Folk-Rock","Nati
onal Folk","Swing","Fast
Fusion","Bebob","Latin","Reviv
al","Celtic","Bluegrass", 
                    "Avantgarde","Gothic
Rock","Progressive Rock","Psychedelic
Rock","Symphonic Rock","Slow
Rock","Big
Band","Chorus","Easy
Listening","Acoustic", 
                   
"Humour","Speech","Chanson",&q
uot;Opera","Chamber
Music","Sonata","Symphony","Bo
oty Bass","Primus","Porn
Groove","Satire","Slow
Jam","Club", 
                   
"Tango","Samba","Folklore",&qu
ot;Ballad","Power Ballad","Rhytmic
Soul","Freestyle","Duet","Punk
Rock","Drum
Solo","Acapella","Euro-House", 
                    "Dance
Hall","Goa","Drum &
Bass","Club-House","Hardcore","
;Terror","Indie","BritPop","Ne
gerpunk","Polsk
Punk","Beat","Christian Gangsta
Rap", 
                    "Heavy Metal","Black
Metal","Crossover","Contemporary
Christian","Christian
Rock","Merengue","Salsa","Tras
h
Metal","Anime","Jpop","Synthpo
p"); 
     
    //id3v2 check---------------------------- 
     
        $footer = 0; 
        $header = 0; 
        $v1tag    = 0; 
        $fp = fopen($this->wave_filename,"r"); 
        $tmp = fread($fp,3); 
        if($tmp == "ID3") 
        { 
            $tmp     = ord(fread($fp,1)); 
            $tmp2     = ord(fread($fp,1)); 
           
$info["mpeg_id3v2_tag"]["version"] =
"ID3v2.".$tmp.".".$tmp2; 
            $tmp     = ord(fread($fp,1)); 
            if($tmp &
128)$info["mpeg_id3v2_tag"]["flag"][&quo
t;unsync"] = "set"; 
            if($tmp & 64)
$info["mpeg_id3v2_tag"]["flag"]["ex
tended"] = "set"; 
            if($tmp & 32)
$info["mpeg_id3v2_tag"]["flag"]["ex
perimental"] = "set"; 
            if($tmp & 16) 
            { 
               
$info["mpeg_id3v2_tag"]["flag"]["fo
oter"] = "set"; 
                $footer = 10; 
            } 
            $tmp     = ord(fread($fp,1))& 127; 
            $tmp2     = ord(fread($fp,1))& 127; 
            $tmp3    = ord(fread($fp,1))& 127; 
            $tmp4     = ord(fread($fp,1))& 127; 
           
$info["mpeg_id3v2_tag"]["header_lenght"]
= ($tmp * 2097152) + ($tmp2 * 16384) + ($tmp3 * 128) + $tmp4
+ 10 + $footer; 
            fseek
($fp,$info["mpeg_id3v2_tag"]["header_lenght&q
uot;]); 
            $header =
$info["mpeg_id3v2_tag"]["header_lenght"]
; 
        } else { 
            fseek ($fp,0); 
            $info["mpeg_id3v2_tag"] = false; 
        } 
     
        for ($x=0;$x<4;$x++) 
        { 
            $byte[$x] = ord(fread($fp,1)); 
        } 
        fseek ($fp, -128 ,SEEK_END); 
        $TAG = fread($fp,128); 
        fclose($fp); 
     
    //id tag?------------------------------- 
     
        if(substr($TAG,0,3) == "TAG") 
        { 
            $v1tag = 128; 
           
$info["mpeg_id3v1_tag"]["title"]     =
substr($TAG,3,30); 
           
$info["mpeg_id3v1_tag"]["artist"]     =
substr($TAG,33,30); 
           
$info["mpeg_id3v1_tag"]["album"]     =
substr($TAG,63,30); 
           
$info["mpeg_id3v1_tag"]["year"]     =
substr($TAG,93,4); 
           
$info["mpeg_id3v1_tag"]["comment"]     =
substr($TAG,97,30); 
           
$info["mpeg_id3v1_tag"]["genre"]    =
""; 
            $tmp = ord(substr($TAG,127,1)); 
            if($tmp < count($genre)) 
            { 
               
$info["mpeg_id3v1_tag"]["genre"] =
$genre[$tmp]; 
            } 
        } else { 
            $info["mpeg_id3v1_tag"] = false; 
        } 
     
    //version------------------------------- 
     
        $tmp = $byte[1] & 24; 
        $tmp = $tmp >> 3; 
        $info_i["mpeg_version"] = $tmp; 
        $byte_v = $version_bitrate[$tmp]; 
        $byte_vs = $version_sampling[$tmp]; 
        $info["mpeg_version"] = $version[$tmp]; 
     
    //layer--------------------------------- 
     
        $tmp = $byte[2] & 6; 
        $tmp = $tmp >> 1; 
        $info_i["mpeg_layer"] = $tmp; 
        $byte_l = $layer_bitrate[$tmp]; 
        $byte_len = $layer_lengt[$tmp]; 
        $info["mpeg_layer"] = $layer[$tmp]; 
     
    //bitrate------------------------------- 
     
        $tmp = $byte[2] & 240; 
        $tmp = $tmp >> 4; 
        $info_i["mpeg_bitrate"] = $tmp; 
        $info["mpeg_bitrate"] =
$byterate[$byte_v][$byte_l][$tmp]." Kbits/sec."; 
     
    //samplingrate-------------------------- 
     
        $tmp = $byte[2] & 12; 
        $tmp = $tmp >> 2; 
        $info["mpeg_sampling_rate"] =
$samplingrate[$byte_vs][$tmp]; 
     
    //protection---------------------------- 
     
        $tmp = $byte[1] & 1; 
        $info["mpeg_protection"] =
$protection[$tmp]; 
         
    //paddingbit---------------------------- 
     
        $tmp = $byte[2] & 2; 
        $tmp = $tmp >> 1; 
        $byte_pad = $tmp; 
        $info["mpeg_padding_bit"] = $tmp; 
     
    //privatebit---------------------------- 
     
        $tmp = $byte[2] & 1; 
        $byte_prv = $tmp; 
     
    //channel_mode-------------------------- 
     
        $tmp = $byte[3] & 192; 
        $tmp = $tmp >> 6; 
        $info["mpeg_channel_mode"] =
$cannel_mode[$tmp]; 
     
    //copyright----------------------------- 
     
        $tmp = $byte[3] & 8; 
        $tmp = $tmp >> 3; 
        $info["mpeg_copyright"] =
$copyright[$tmp]; 
     
    //original------------------------------ 
     
        $tmp = $byte[3] & 4; 
        $tmp = $tmp >> 2; 
        $info["mpeg_original"] = $original[$tmp]; 
         
    //emphasis------------------------------ 
     
        $tmp = $byte[3] & 3; 
        $info["mpeg_emphasis"] = $emphasis[$tmp]; 
     
    //framelenght--------------------------- 
     
        if($byte_len == 0) 
        { 
            $rate_tmp = $info["mpeg_bitrate"] *
1000; 
            $info["mpeg_framelenght"] = (12 *
$rate_tmp / $info["mpeg_sampling_rate"] +
$byte_pad) * 4 ; 
        } elseif($byte_len == 1) { 
            $rate_tmp = $info["mpeg_bitrate"] *
1000; 
            $info["mpeg_framelenght"] = 144 *
$rate_tmp /  
            $info["mpeg_sampling_rate"] +
$byte_pad; 
        } 
         
    //duration------------------------------ 
     
        $tmp = filesize($this->wave_filename); 
        $tmp = $tmp - $header - 4 - $v1tag; 
        $info["mpeg_frames"] =
floor($tmp/$info["mpeg_framelenght"]); 
        $tmp = $tmp * 8; 
        $info["mpeg_playtime"] = $tmp/$rate_tmp; 
         
        // transfer the extracted data into
classAudioFile-structure 
                         
        $this->wave_id = "MPEG"; 
        $this->wave_type =
$info["mpeg_version"]; 
        $this->wave_compression =
$info["mpeg_layer"]; 
        $this->wave_channels =
$info["mpeg_channel_mode"]; 
        $this->wave_framerate =
$info["mpeg_sampling_rate"]; 
        $this->wave_byterate =
$info["mpeg_bitrate"]; 
        $this->wave_bits = "n/a"; 
        $this->wave_size =
filesize($this->wave_filename); 
        $this->wave_length =
$info["mpeg_playtime"]; 
         
        $this->id3_tag =
$info["mpeg_id3v1_tag"]; 
         
        if ($this->id3_tag) 
        { 
            $this->id3_title =
$info["mpeg_id3v1_tag"]["title"]; 
            $this->id3_artist =
$info["mpeg_id3v1_tag"]["artist"]; 
            $this->id3_album =
$info["mpeg_id3v1_tag"]["album"]; 
            $this->id3_year =
$info["mpeg_id3v1_tag"]["year"]; 
            $this->id3_comment =
$info["mpeg_id3v1_tag"]["comment"]; 
            $this->id3_genre =
$info["mpeg_id3v1_tag"]["genre"]; 
        } 
    } 

    //
************************************************************
************ 
    // longCalc calculates the decimal value of 4 bytes 
    // mode = 0 ... b1 is the byte with least value 
    // mode = 1 ... b1 is the byte with most value 
    //
************************************************************
************             

    function longCalc ($b1,$b2,$b3,$b4,$mode) 
    { 
        $b1 = hexdec(bin2hex($b1));                         
        $b2 = hexdec(bin2hex($b2));                         
        $b3 = hexdec(bin2hex($b3));                         
        $b4 = hexdec(bin2hex($b4));                         
        if ($mode == 0) 
        { 
            return ($b1 + ($b2*256) + ($b3 * 65536) + ($b4 *
16777216));     
        } else { 
            return ($b4 + ($b3*256) + ($b2 * 65536) + ($b1 *
16777216)); 
        } 
    } 

    //
************************************************************
************ 
    // shortCalc calculates the decimal value of 2 bytes 
    // mode = 0 ... b1 is the byte with least value 
    // mode = 1 ... b1 is the byte with most value 
    //
************************************************************
************             

    function shortCalc ($b1,$b2,$mode) 
    { 
        $b1 = hexdec(bin2hex($b1));                         
        $b2 = hexdec(bin2hex($b2));                         
        if ($mode == 0) 
        { 
            return ($b1 + ($b2*256));     
        } else { 
            return ($b2 + ($b1*256)); 
        } 
    } 
     
    //
************************************************************
************ 
    // getCompression delivers a string which identifies the
compression-mode  
    // of the AudioFile-Object  
    //
************************************************************
************ 
     
    function getCompression ($id) 
    { 
        if ($this->wave_id <> "MPEG") 
        { 
            $append = "($id)"; 
            switch ($id) 
            { 
                case 0:  return ("unknown
$append"); break; 
                case 1:  return ("pcm/uncompressed
$append"); break; 
                case 2:  return ("microsoft adpcm
$append"); break; 
                case 6:  return ("itu g.711 a-law
$append"); break; 
                case 7:  return ("itu g.711 u-law
$append"); break;             
                case 17:   return ("ima adpcm
$append"); break; 
                case 20:   return ("itu g.723 adpcm
(yamaha) $append"); break; 
                case 49:   return ("gsm 6.10
$append"); break; 
                case 64:   return ("itu g.721 adpcm
$append"); break; 
                case 80:   return ("mpeg
$append"); break; 
                case 65536:return ("experimental
$append"); break; 
                default:   return ("not defined
$append"); break; 
            }     
        } else { 
            return ($id);     
        } 
    } 
     
    //
************************************************************
************ 
    // getVisualization creates a graphical visualization of
the audio-sample 
    //                  (works ONLY * for uncompressed
waves! 
    //                              * files with 1 or 2
channels 
    //                              * 8/16/24/32 bit
sample-resolution ) 
    //
************************************************************
************             
     
    function getVisualization ($output) 
    { 
        $width=$this->visual_width; 
        if ($this->wave_filename<>""
&& $this->wave_id == "RIFF" &&
$this->wave_type == "WAVE" &&
($this->wave_channels>=1 &&
$this->wave_channels<=2) &&
$this->wave_bits%8==0) 
        { 
            $file = fopen
($this->wave_filename,"r"); 
             
            // read the first 12 bytes (RIFF- &
WAVE-chunk) 
             
            for ($i=0;$i<12;$i++) 
            { 
                $null = fgetc ($file);     
            } 
             
            // Read the next chunk-id, supposed to be
"fmt " 
             
            $chunk_id_3 = fgetc($file) . fgetc($file) .
fgetc($file) . fgetc($file); 
            if ($chunk_id_3 == "fmt ") 
            { 
                $chunk_size_3 = $this->longCalc
(fgetc($file) , fgetc($file) , fgetc($file) ,
fgetc($file),0); 
                for ($i=0;$i<$chunk_size_3;$i++) 
                { 
                    $null = fgetc($file); 
                }             
                 
                // Read the next chunk-id, supposed to be
"data"                 
                 
                $chunk_id_4 = fgetc($file) . fgetc($file) .
fgetc($file) . fgetc($file); 
                if ($chunk_id_4 == "data") 
                { 
                    $chunk_size_4 = $this->longCalc
(fgetc($file) , fgetc($file) , fgetc($file) ,
fgetc($file),0); 
                    $visualData = array(); 
                    $bytes_per_frame =
($this->wave_bits/8)*($this->wave_channels); 
                    $bytes_per_channel =
($this->wave_bits/8); 
                    $frames = $chunk_size_4 /
$bytes_per_frame; 
                    $visual_frames = ceil($frames / $width);

                    $frame_index = 1; 
                    $data_index = 1; 
                    while (!feof($file)) 
                    {                                       
         
                        for
($j=0;$j<$this->wave_channels;$j++) 
                        { 
                            $bytes = array(); 
                            for
($i=0;$i<$bytes_per_channel;$i++) 
                            { 
                                $bytes[$i] = fgetc($file); 
                            } 
                            if ($frame_index ==
$visual_frames) 
                            { 
                                switch ($bytes_per_channel) 
                                { 
                                    case 1:
$visualData[$j][$data_index]=
$this->shortCalc($bytes[0],$bytes[1],0);  
                                        break; 
                                    case 2: $f=128; 
                                        if
(ord($bytes[1])&128) $f = 0; 
                                       
$x=chr((ord($bytes[1])&127) + $f); 
                                       
$visualData[$j][$data_index]=
floor($this->shortCalc($bytes[0],$x,0)/256);  
                                        break; 
                                }                           
             
                                if (($j+1) ==
$this->wave_channels) 
                                { 
                                    $data_index++;          
                          
                                    $frame_index = 1;     
                                } 
                            } else { 
                                if (($j+1) ==
$this->wave_channels) $frame_index++; 
                            }                             
                        }                         
                    }                     
                    $im = ImageCreate ($width,
(256*$this->wave_channels)+1) or die ("Cannot
Initialize new GD image stream!"); 
                    $background_color = ImageColorAllocate
($im,
hexdec(substr($this->visual_background_color,1,2)),hexdec
(substr($this->visual_background_color,3,2)),hexdec(subst
r($this->visual_background_color,5,2))); 
                    $cBlack = ImageColorAllocate ($im,
hexdec(substr($this->visual_background_color,1,2)),hexdec
(substr($this->visual_background_color,3,2)),hexdec(subst
r($this->visual_background_color,5,2))); 
                    $cGreen = ImageColorAllocate ($im,
hexdec(substr($this->visual_graph_color,1,2)),hexdec(subs
tr($this->visual_graph_color,3,2)),hexdec(substr($this-&g
t;visual_graph_color,5,2))); 
                    $cRed = ImageColorAllocate ($im,
hexdec(substr($this->visual_border_color,1,2)),hexdec(sub
str($this->visual_border_color,3,2)),hexdec(substr($this-
>visual_border_color,5,2))); 
                    $cBlue = ImageColorAllocate ($im,
hexdec(substr($this->visual_grid_color,1,2)),hexdec(subst
r($this->visual_grid_color,3,2)),hexdec(substr($this->
visual_grid_color,5,2))); 
                    if ($this->visual_border) 
                    { 
                        ImageRectangle
($im,0,0,($width-1),(256*$this->wave_channels),$cRed); 
                        for
($i=0;$i<=$this->wave_channels;$i++) 
                        {                     
                            ImageLine
($im,1,($i*128)+128,$width,($i*128)+128,$cRed); 
                        } 
                    } 
                    if ($this->visual_grid) 
                    { 
                        for
($i=1;$i<=($width/100*2);$i++) 
                        { 
                            ImageLine
($im,$i*50,0,$i*50,(256*$this->wave_channels),$cBlue); 
                        }                     
                    } 
                     
                    // this for-loop draws a graph for every
channel 
                     
                    for
($j=0;$j<sizeof($visualData);$j++) 
                    { 
                        $last_x = 1; 
                        $last_y = 128; 
                         
                        // this for-loop draws the graph
itself 
                         
                        for
($i=1;$i<sizeof($visualData[$j]);$i++) 
                        { 
                            ImageLine
($im,$last_x,($last_y+($j*256)),$i,($visualData[$j][$i]+($j*
256)),$cGreen); 
                            $last_x = $i; 
                            $last_y = $visualData[$j][$i]; 
                        } 
                    } 
                     
                    // change this to generate JPG or direct
output to browser 
                     
                    ImagePng ($im,$output); 
                } 
            } 
            fclose ($file); 
        } else { 
            // AudioSample - AudioFile-Object not
initialized! 
        } 
    } 
     
    //
************************************************************
************ 
    // getSampleInfo extracts the attributes of the
AudioFile-Object 
    //
************************************************************
************             

    function getSampleInfo () 
    {                 
        $valid = true; 

        if
(strstr(strtoupper($this->wave_filename),"MP3")
) 
        { 
            $this->mp3info (); 
        } else { 
         
            $this->wave_size = filesize
($this->wave_filename); 
            if ($this->wave_size > 16) 
            { 
                 
                $file = fopen
($this->wave_filename,"r"); 
                $chunk_id = fgetc($file) . fgetc($file) .
fgetc($file) . fgetc($

----- Original Message ----
From: chitara1970 <chitara1970yahoo.com>
To: php-objects@yahoogroups.com
Sent: Sunday, December 10, 2006 9:16:42 AM
Subject: [php-objects] to get the length or
play-time/duration









  


    
            Hi guys!! 



can anyone please tell me how to convert a audio file size
to length. 

Say I have a file(abc.mpeg) which is 4.6 MB in size &
its length is 

4.58 minutes. 

So is there any function in php by which i can get the
length from the 

size of that file?? 



maybe the sound is so silly but please help me!! 



actually I need to get the length or play-time of each song.




I kept the file into a foleder & there name is in the
database. 



Can anyone know any way to get the length of music file??? 



Regards  





    
  

    
    




<!--

#ygrp-mlmsg
{font-size:13px;font-family:arial,helvetica,clean,sans-serif
;}
#ygrp-mlmsg table {font-size:inherit;font:100%;}
#ygrp-mlmsg select, input, textarea {font:99%
arial,helvetica,clean,sans-serif;}
#ygrp-mlmsg pre, code {font:115% monospace;}
#ygrp-mlmsg * {line-height:1.22em;}
#ygrp-text{
font-family:Georgia;
}
#ygrp-text p{
margin:0 0 1em 0;
}
#ygrp-tpmsgs{
font-family:Arial;
clear:both;
}
#ygrp-vitnav{
padding-top:10px;
font-family:Verdana;
font-size:77%;
margin:0;
}
#ygrp-vitnav a{
padding:0 1px;
}
#ygrp-actbar{
clear:both;
margin:25px 0;
white-space:nowrap;
color:#666;
text-align:right;
}
#ygrp-actbar .left{
float:left;
white-space:nowrap;
}
.bld{font-weight:bold;}
#ygrp-grft{
font-family:Verdana;
font-size:77%;
padding:15px 0;
}
#ygrp-ft{
font-family:verdana;
font-size:77%;
border-top:1px solid #666;
padding:5px 0;
}
#ygrp-mlmsg #logo{
padding-bottom:10px;
}

#ygrp-vital{
background-color:#e0ecee;
margin-bottom:20px;
padding:2px 0 8px 8px;
}
#ygrp-vital #vithd{
font-size:77%;
font-family:Verdana;
font-weight:bold;
color:#333;
text-transform:uppercase;
}
#ygrp-vital ul{
padding:0;
margin:2px 0;
}
#ygrp-vital ul li{
list-style-type:none;
clear:both;
border:1px solid #e0ecee;
}
#ygrp-vital ul li .ct{
font-weight:bold;
color:#ff7900;
float:right;
width:2em;
text-align:right;
padding-right:.5em;
}
#ygrp-vital ul li .cat{
font-weight:bold;
}
#ygrp-vital a {
text-decoration:none;
}

#ygrp-vital a:hover{
text-decoration:underline;
}

#ygrp-sponsor #hd{
color:#999;
font-size:77%;
}
#ygrp-sponsor #ov{
padding:6px 13px;
background-color:#e0ecee;
margin-bottom:20px;
}
#ygrp-sponsor #ov ul{
padding:0 0 0 8px;
margin:0;
}
#ygrp-sponsor #ov li{
list-style-type:square;
padding:6px 0;
font-size:77%;
}
#ygrp-sponsor #ov li a{
text-decoration:none;
font-size:130%;
}
#ygrp-sponsor #nc {
background-color:#eee;
margin-bottom:20px;
padding:0 8px;
}
#ygrp-sponsor .ad{
padding:8px 0;
}
#ygrp-sponsor .ad #hd1{
font-family:Arial;
font-weight:bold;
color:#628c2a;
font-size:100%;
line-height:122%;
}
#ygrp-sponsor .ad a{
text-decoration:none;
}
#ygrp-sponsor .ad a:hover{
text-decoration:underline;
}
#ygrp-sponsor .ad p{
margin:0;
}
o {font-size:0;}
.MsoNormal {
margin:0 0 0 0;
}
#ygrp-text tt{
font-size:120%;
}
blockquote{margin:0 0 0 4px;}
.replbq {margin:4;}
-->








 
____________________________________________________________
________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.c
om/unlimited

[Non-text portions of this message have been removed]



PHP Data object relational mapping generator
http://www.metastorage.ne
t/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://gro
ups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http:/
/groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:php-objects-digest@yahoogroups.com 
    mailto:php-objects-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 
to get the length or play-time/duration
user name
2006-12-18 11:18:59
Hi guys!!
Thanks for your responds. But i am doing something else.
In my jukebox there is a facility to select multiple audio
tracks 
with checkbox. Then the selected tracks will play with my
defined 
player one after another. But here when I select more then
one track 
the tracks play all together. I am sending the code in
below. Can 
anybody please help me regarding this????

[code]
<?php

include "../admin/include/db.php";


$file=$_GET['track'];
//var_dump($file);

if($file != null)
   {
      for($i=0; $i < sizeof($file); $i++)
      {
               $music = $file[$i];

    $result=mysql_query("select * from musiclibrary
where 
music_no='$music'");
    
    while($row=mysql_fetch_array($result)){
        $play_no=$row['music_no'];        
        //$play=$row['file_name'];
        

    }
    
    $sql_result=mysql_query("select file_name from
musiclibrary 
where music_no='$play_no'");
      
        while($rows=mysql_fetch_array($sql_result)){
        $play=$rows['file_name'];        
         
         
?>
<html>
<head>
<title>Player</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-
1">
</head>

<div id="Layer1" style="position:absolute;
width:300; height:300; z-
index:2; left: -2px; top: -2px; background-color: #000000;
layer-
background-color: #000000; border: 1px none
#000000"> 
  

<OBJECT ID="MediaPlayer" WIDTH=300 HEIGHT=300
  
classid="clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95&quo
t;
   STANDBY="Loading Media Player components"
   TYPE="application/x-oleobject"
   codebase="http://activex
.microsoft.com">

  <PARAM NAME = "autostart" VALUE =
"True" >
  <PARAM NAME = "filename" VALUE =
"<?print $mdir."/".$play;?>" >

</OBJECT>

    
</div>

</body>
</html><?
        
}    
}//var_dump($music);
   }            
?>
[/code]

my table structute is>>

CREATE TABLE `musiclibrary` (
  `music_no` int(11) NOT NULL auto_increment,
  `music_name` varchar(100) default NULL,
  `file_name` varchar(100) default NULL,
  `playtime` varchar(200) NOT NULL default '',
  `music_day` decimal(10,0) default NULL,
  `cat_id` decimal(10,0) default NULL,
  PRIMARY KEY  (`music_no`),
  UNIQUE KEY `music_no` (`music_no`),
  KEY `cat_id` (`cat_id`)
);

I am waiting ....

Regards

--- In php-objects@yahoogroups.com, Prasanth
<prassunair...> wrote:
>
> Chithra,
> I know ur Intention ...
> plz use this one  , this is apt for ur requirements,
> have a nice time,
> Prasanth Nair
> <?php 
> 
> // 
************************************************************
*********
*** 
> // Class    AudioFile 
> // Version: 0.4 
> // Date:    24/04/2002 
> // Author:  michael kamleitner (mika...) 
> //        reto gassmann (gassi...) - additional mp3-code 
> // WWW:        http://www.entropy.a
t/forum.php?
action=thread&t_id=15  
> //          (suggestions, bug-reports & general
shouts are 
welcome) 
> // 
************************************************************
*********
*** 
> 
> class AudioFile 
> { 
>     var $wave_id; 
>     var $wave_type; 
>     var $wave_compression; 
>     var $wave_channels; 
>     var $wave_framerate; 
>     var $wave_byterate; 
>     var $wave_bits; 
>     var $wave_size; 
>     var $wave_filename; 
>     var $wave_length; 
>      
>     var $id3_tag; 
>     var $id3_title; 
>     var $id3_artist; 
>     var $id3_album; 
>     var $id3_year; 
>     var $id3_comment; 
>     var $id3_genre; 
>      
>     var $visual_graph_color; 
>     var $visual_background_color; 
>     var $visual_grid_color; 
>     var $visual_border_color; 
>     var $visual_grid; 
>     var $visual_border; 
>     var $visual_width; 
> 
>     // 
************************************************************
*********
*** 
>     // mp3info extracts the attributes of mp3-files 
>     // (code contributed by reto gassmann (gassi...) 
>     // 
************************************************************
*********
***             
>      
>     function mp3info() 
>     { 
>         $byte             = array(); 
>         $version         = array("MPEG Version
2.5",false,"MPEG 
Version 2 (ISO/IEC 13818-3)","MPEG Version 1
(ISO/IEC 11172-3)"); 
>         $version_bitrate    = array(1,false,1,0); 
>         $version_sampling    = array(2,false,1,0); 
>         $layer            = array(false,"Layer
III","Layer 
II","Layer I"); 
>         $layer_bitrate        = array(false,2,1,0); 
>         $layer_lengt        = array(false,1,1,0); 
>         $protection         = array("Protected by
CRC (16bit crc 
follows header)","Not protected"); 
>         $byterate        = array( 
>                         array( 
>                             array
("free",32,64,96,128,160,192,224,256,288,320,352,3
84,416,448,"bad"), 
>                            
array("free",32,48,56, 64, 80, 
96,112,128,160,192,224,256,320,384,"bad"), 
>                            
array("free",32,40,48, 56, 64, 80, 
96,112,128,160,192,224,256,320,"bad") 
>                              ), 
>                         array( 
>                            
array("free",32,48,56, 64, 80, 
96,112,128,144,160,176,192,224,256,"bad"), 
>                             array("free",
8,16,24, 32, 40, 48, 56, 
64, 80, 96,112,128,144,160,"bad"), 
>                             array("free",
8,16,24, 32, 40, 48, 56, 
64, 80, 96,112,128,144,160,"bad") 
>                              ) 
>                            ); 
>         $samplingrate        = array( 
>                         array(44100,48000,32000,false),

>                         array(22050,24000,16000,false),

>                         array(11025,12000, 8000,false) 
>                            ); 
>         $cannel_mode    =
array("Stereo","Joint stereo 
(Stereo)","Dual channel
(Stereo)","Single channel (Mono)"); 
>         $copyright    = array("Audio is not
copyrighted","Audio is 
copyrighted "); 
>         $original    = array("Copy of original
media","Original 
media");  
>         $emphasis    =
array("none","50/15 ms",false,"CCIT

J.17 "); 
>      
>     //id3-stuff 
>      
>     $genre            = array 
>                     ("Blues","Classic 
Rock","Country","Dance","Disco
","Funk","Grunge","Hip-
Hop","Jazz","Metal","New
Age","Oldies","Other","Pop&quo
t;,"R&B", 
>                    
"Rap","Reggae","Rock","Te
chno","Industrial","Al
ternative","Ska","Death
Metal","Pranks","Soundtrack","
Euro-
Techno","Ambient","Trip-Hop", 
>                    
"Vocal","Jazz+Funk","Fusion",&
quot;Trance","Classica
l","Instrumental","Acid","Hous
e","Game","Sound 
Clip","Gospel","Noise","Altern
ative Rock", 
>                    
"Bass","Soul","Punk","Spa
ce","Meditative","Inst
rumental Pop","Instrumental 
Rock","Ethnic","Gothic","Darkw
ave","Techno-Industrial", 
>                     "Electronic","Pop-
Folk","Eurodance","Dream","Sou
thern 
Rock","Comedy","Cult","Gangsta
","Top 40","Christian 
Rap","Pop/Funk","Jungle", 
>                     "Native
US","Cabaret","New 
Wave","Psychadelic","Rave","Sh
owtunes","Trailer","Lo-
Fi","Tribal","Acid Punk","Acid
Jazz","Polka","Retro", 
>                     "Musical","Rock
& Roll","Hard 
Rock","Folk","Folk-Rock","Nati
onal Folk","Swing","Fast 
Fusion","Bebob","Latin","Reviv
al","Celtic","Bluegrass", 
>                     "Avantgarde","Gothic
Rock","Progressive 
Rock","Psychedelic Rock","Symphonic
Rock","Slow Rock","Big 
Band","Chorus","Easy
Listening","Acoustic", 
>                    
"Humour","Speech","Chanson",&q
uot;Opera","Chamber 
Music","Sonata","Symphony","Bo
oty Bass","Primus","Porn 
Groove","Satire","Slow
Jam","Club", 
>                    
"Tango","Samba","Folklore",&qu
ot;Ballad","Power 
Ballad","Rhytmic
Soul","Freestyle","Duet","Punk
Rock","Drum 
Solo","Acapella","Euro-House", 
>                     "Dance
Hall","Goa","Drum &
Bass","Club-
House","Hardcore","Terror","In
die","BritPop","Negerpunk","Po
lsk 
Punk","Beat","Christian Gangsta
Rap", 
>                     "Heavy Metal","Black

Metal","Crossover","Contemporary
Christian","Christian 
Rock","Merengue","Salsa","Tras
h
Metal","Anime","Jpop","Synthpo
p"); 
>      
>     //id3v2 check---------------------------- 
>      
>         $footer = 0; 
>         $header = 0; 
>         $v1tag    = 0; 
>         $fp =
fopen($this->wave_filename,"r"); 
>         $tmp = fread($fp,3); 
>         if($tmp == "ID3") 
>         { 
>             $tmp     = ord(fread($fp,1)); 
>             $tmp2     = ord(fread($fp,1)); 
>            
$info["mpeg_id3v2_tag"]["version"] 
= "ID3v2.".$tmp.".".$tmp2; 
>             $tmp     = ord(fread($fp,1)); 
>             if($tmp &
128)$info["mpeg_id3v2_tag"]["flag"]
["unsync"] = "set"; 
>             if($tmp & 64)
$info["mpeg_id3v2_tag"]["flag"]
["extended"] = "set"; 
>             if($tmp & 32)
$info["mpeg_id3v2_tag"]["flag"]
["experimental"] = "set"; 
>             if($tmp & 16) 
>             { 
>                
$info["mpeg_id3v2_tag"]["flag"]["fo
oter"] = "set"; 
>                 $footer = 10; 
>             } 
>             $tmp     = ord(fread($fp,1))& 127; 
>             $tmp2     = ord(fread($fp,1))& 127; 
>             $tmp3    = ord(fread($fp,1))& 127; 
>             $tmp4     = ord(fread($fp,1))& 127; 
>            
$info["mpeg_id3v2_tag"]["header_lenght"]
= ($tmp * 
2097152) + ($tmp2 * 16384) + ($tmp3 * 128) + $tmp4 + 10 +
$footer; 
>             fseek
($fp,$info["mpeg_id3v2_tag"]["header_lenght&q
uot;]); 
>             $header =
$info["mpeg_id3v2_tag"]["header_lenght"]
; 
>         } else { 
>             fseek ($fp,0); 
>             $info["mpeg_id3v2_tag"] = false; 
>         } 
>      
>         for ($x=0;$x<4;$x++) 
>         { 
>             $byte[$x] = ord(fread($fp,1)); 
>         } 
>         fseek ($fp, -128 ,SEEK_END); 
>         $TAG = fread($fp,128); 
>         fclose($fp); 
>      
>     //id tag?------------------------------- 
>      
>         if(substr($TAG,0,3) == "TAG") 
>         { 
>             $v1tag = 128; 
>            
$info["mpeg_id3v1_tag"]["title"]     =
substr
($TAG,3,30); 
>            
$info["mpeg_id3v1_tag"]["artist"]     =
substr
($TAG,33,30); 
>            
$info["mpeg_id3v1_tag"]["album"]     =
substr
($TAG,63,30); 
>            
$info["mpeg_id3v1_tag"]["year"]     =
substr
($TAG,93,4); 
>            
$info["mpeg_id3v1_tag"]["comment"]     =
substr
($TAG,97,30); 
>            
$info["mpeg_id3v1_tag"]["genre"]    =
""; 
>             $tmp = ord(substr($TAG,127,1)); 
>             if($tmp < count($genre)) 
>             { 
>                
$info["mpeg_id3v1_tag"]["genre"] =
$genre[$tmp]; 
>             } 
>         } else { 
>             $info["mpeg_id3v1_tag"] = false; 
>         } 
>      
>     //version------------------------------- 
>      
>         $tmp = $byte[1] & 24; 
>         $tmp = $tmp >> 3; 
>         $info_i["mpeg_version"] = $tmp; 
>         $byte_v = $version_bitrate[$tmp]; 
>         $byte_vs = $version_sampling[$tmp]; 
>         $info["mpeg_version"] =
$version[$tmp]; 
>      
>     //layer--------------------------------- 
>      
>         $tmp = $byte[2] & 6; 
>         $tmp = $tmp >> 1; 
>         $info_i["mpeg_layer"] = $tmp; 
>         $byte_l = $layer_bitrate[$tmp]; 
>         $byte_len = $layer_lengt[$tmp]; 
>         $info["mpeg_layer"] = $layer[$tmp]; 
>      
>     //bitrate------------------------------- 
>      
>         $tmp = $byte[2] & 240; 
>         $tmp = $tmp >> 4; 
>         $info_i["mpeg_bitrate"] = $tmp; 
>         $info["mpeg_bitrate"] =
$byterate[$byte_v][$byte_l]
[$tmp]." Kbits/sec."; 
>      
>     //samplingrate-------------------------- 
>      
>         $tmp = $byte[2] & 12; 
>         $tmp = $tmp >> 2; 
>         $info["mpeg_sampling_rate"] =
$samplingrate[$byte_vs]
[$tmp]; 
>      
>     //protection---------------------------- 
>      
>         $tmp = $byte[1] & 1; 
>         $info["mpeg_protection"] =
$protection[$tmp]; 
>          
>     //paddingbit---------------------------- 
>      
>         $tmp = $byte[2] & 2; 
>         $tmp = $tmp >> 1; 
>         $byte_pad = $tmp; 
>         $info["mpeg_padding_bit"] = $tmp; 
>      
>     //privatebit---------------------------- 
>      
>         $tmp = $byte[2] & 1; 
>         $byte_prv = $tmp; 
>      
>     //channel_mode-------------------------- 
>      
>         $tmp = $byte[3] & 192; 
>         $tmp = $tmp >> 6; 
>         $info["mpeg_channel_mode"] =
$cannel_mode[$tmp]; 
>      
>     //copyright----------------------------- 
>      
>         $tmp = $byte[3] & 8; 
>         $tmp = $tmp >> 3; 
>         $info["mpeg_copyright"] =
$copyright[$tmp]; 
>      
>     //original------------------------------ 
>      
>         $tmp = $byte[3] & 4; 
>         $tmp = $tmp >> 2; 
>         $info["mpeg_original"] =
$original[$tmp]; 
>          
>     //emphasis------------------------------ 
>      
>         $tmp = $byte[3] & 3; 
>         $info["mpeg_emphasis"] =
$emphasis[$tmp]; 
>      
>     //framelenght--------------------------- 
>      
>         if($byte_len == 0) 
>         { 
>             $rate_tmp = $info["mpeg_bitrate"]
* 1000; 
>             $info["mpeg_framelenght"] = (12 *
$rate_tmp / $info
["mpeg_sampling_rate"] + $byte_pad) * 4 ; 
>         } elseif($byte_len == 1) { 
>             $rate_tmp = $info["mpeg_bitrate"]
* 1000; 
>             $info["mpeg_framelenght"] = 144 *
$rate_tmp /  
>             $info["mpeg_sampling_rate"] +
$byte_pad; 
>         } 
>          
>     //duration------------------------------ 
>      
>         $tmp = filesize($this->wave_filename); 
>         $tmp = $tmp - $header - 4 - $v1tag; 
>         $info["mpeg_frames"] =
floor($tmp/$info
["mpeg_framelenght"]); 
>         $tmp = $tmp * 8; 
>         $info["mpeg_playtime"] =
$tmp/$rate_tmp; 
>          
>         // transfer the extracted data into
classAudioFile-
structure 
>                          
>         $this->wave_id = "MPEG"; 
>         $this->wave_type =
$info["mpeg_version"]; 
>         $this->wave_compression =
$info["mpeg_layer"]; 
>         $this->wave_channels =
$info["mpeg_channel_mode"]; 
>         $this->wave_framerate =
$info["mpeg_sampling_rate"]; 
>         $this->wave_byterate =
$info["mpeg_bitrate"]; 
>         $this->wave_bits = "n/a"; 
>         $this->wave_size =
filesize($this->wave_filename); 
>         $this->wave_length =
$info["mpeg_playtime"]; 
>          
>         $this->id3_tag =
$info["mpeg_id3v1_tag"]; 
>          
>         if ($this->id3_tag) 
>         { 
>             $this->id3_title =
$info["mpeg_id3v1_tag"]["title"]; 
>             $this->id3_artist =
$info["mpeg_id3v1_tag"]["artist"]; 
>             $this->id3_album =
$info["mpeg_id3v1_tag"]["album"]; 
>             $this->id3_year =
$info["mpeg_id3v1_tag"]["year"]; 
>             $this->id3_comment =
$info["mpeg_id3v1_tag"]
["comment"]; 
>             $this->id3_genre =
$info["mpeg_id3v1_tag"]["genre"]; 
>         } 
>     } 
> 
>     // 
************************************************************
*********
*** 
>     // longCalc calculates the decimal value of 4 bytes

>     // mode = 0 ... b1 is the byte with least value 
>     // mode = 1 ... b1 is the byte with most value 
>     // 
************************************************************
*********
***             
> 
>     function longCalc ($b1,$b2,$b3,$b4,$mode) 
>     { 
>         $b1 = hexdec(bin2hex($b1));                    
    
>         $b2 = hexdec(bin2hex($b2));                    
    
>         $b3 = hexdec(bin2hex($b3));                    
    
>         $b4 = hexdec(bin2hex($b4));                    
    
>         if ($mode == 0) 
>         { 
>             return ($b1 + ($b2*256) + ($b3 * 65536) +
($b4 * 
16777216));     
>         } else { 
>             return ($b4 + ($b3*256) + ($b2 * 65536) +
($b1 * 
16777216)); 
>         } 
>     } 
> 
>     // 
************************************************************
*********
*** 
>     // shortCalc calculates the decimal value of 2
bytes 
>     // mode = 0 ... b1 is the byte with least value 
>     // mode = 1 ... b1 is the byte with most value 
>     // 
************************************************************
*********
***             
> 
>     function shortCalc ($b1,$b2,$mode) 
>     { 
>         $b1 = hexdec(bin2hex($b1));                    
    
>         $b2 = hexdec(bin2hex($b2));                    
    
>         if ($mode == 0) 
>         { 
>             return ($b1 + ($b2*256));     
>         } else { 
>             return ($b2 + ($b1*256)); 
>         } 
>     } 
>      
>     // 
************************************************************
*********
*** 
>     // getCompression delivers a string which
identifies the 
compression-mode  
>     // of the AudioFile-Object  
>     // 
************************************************************
*********
*** 
>      
>     function getCompression ($id) 
>     { 
>         if ($this->wave_id <>
"MPEG") 
>         { 
>             $append = "($id)"; 
>             switch ($id) 
>             { 
>                 case 0:  return ("unknown
$append"); break; 
>                 case 1:  return ("pcm/uncompressed
$append"); 
break; 
>                 case 2:  return ("microsoft adpcm
$append"); 
break; 
>                 case 6:  return ("itu g.711 a-law
$append"); 
break; 
>                 case 7:  return ("itu g.711 u-law
$append"); 
break;             
>                 case 17:   return ("ima adpcm
$append"); break; 
>                 case 20:   return ("itu g.723
adpcm (yamaha) 
$append"); break; 
>                 case 49:   return ("gsm 6.10
$append"); break; 
>                 case 64:   return ("itu g.721
adpcm $append"); 
break; 
>                 case 80:   return ("mpeg
$append"); break; 
>                 case 65536:return ("experimental
$append"); break; 
>                 default:   return ("not defined
$append"); break; 
>             }     
>         } else { 
>             return ($id);     
>         } 
>     } 
>      
>     // 
************************************************************
*********
*** 
>     // getVisualization creates a graphical
visualization of the 
audio-sample 
>     //                  (works ONLY * for uncompressed
waves! 
>     //                              * files with 1 or 2
channels 
>     //                              * 8/16/24/32 bit
sample-
resolution ) 
>     // 
************************************************************
*********
***             
>      
>     function getVisualization ($output) 
>     { 
>         $width=$this->visual_width; 
>         if ($this->wave_filename<>""
&& $this->wave_id == "RIFF" 
&& $this->wave_type == "WAVE"
&& ($this->wave_channels>=1 && $this-
>wave_channels<=2) &&
$this->wave_bits%8==0) 
>         { 
>             $file = fopen
($this->wave_filename,"r"); 
>              
>             // read the first 12 bytes (RIFF- &
WAVE-chunk) 
>              
>             for ($i=0;$i<12;$i++) 
>             { 
>                 $null = fgetc ($file);     
>             } 
>              
>             // Read the next chunk-id, supposed to be
"fmt " 
>              
>             $chunk_id_3 = fgetc($file) . fgetc($file) .
fgetc
($file) . fgetc($file); 
>             if ($chunk_id_3 == "fmt ") 
>             { 
>                 $chunk_size_3 = $this->longCalc
(fgetc($file) , 
fgetc($file) , fgetc($file) , fgetc($file),0); 
>                 for ($i=0;$i<$chunk_size_3;$i++) 
>                 { 
>                     $null = fgetc($file); 
>                 }             
>                  
>                 // Read the next chunk-id, supposed to 
be "data"                 
>                  
>                 $chunk_id_4 = fgetc($file) .
fgetc($file) . fgetc
($file) . fgetc($file); 
>                 if ($chunk_id_4 == "data") 
>                 { 
>                     $chunk_size_4 = $this->longCalc
(fgetc
($file) , fgetc($file) , fgetc($file) , fgetc($file),0); 
>                     $visualData = array(); 
>                     $bytes_per_frame =
($this->wave_bits/8)*($this-
>wave_channels); 
>                     $bytes_per_channel =
($this->wave_bits/8); 
>                     $frames = $chunk_size_4 /
$bytes_per_frame; 
>                     $visual_frames = ceil($frames /
$width); 
>                     $frame_index = 1; 
>                     $data_index = 1; 
>                     while (!feof($file)) 
>                     
{                                                 
>                         for
($j=0;$j<$this->wave_channels;$j++) 
>                         { 
>                             $bytes = array(); 
>                             for
($i=0;$i<$bytes_per_channel;$i++) 
>                             { 
>                                 $bytes[$i] =
fgetc($file); 
>                             } 
>                             if ($frame_index ==
$visual_frames) 
>                             { 
>                                 switch
($bytes_per_channel) 
>                                 { 
>                                     case 1:
$visualData[$j]
[$data_index]= $this->shortCalc($bytes[0],$bytes[1],0);  
>                                         break; 
>                                     case 2: $f=128; 
>                                         if
(ord($bytes[1])&128) $f 
= 0; 
>                                        
$x=chr((ord($bytes[1])
&127) + $f); 
>                                         $visualData[$j]
[$data_index]=
floor($this->shortCalc($bytes[0],$x,0)/256);  
>                                         break; 
>                                 }                      
           
       
>                                 if (($j+1) == $this-
>wave_channels) 
>                                 { 
>                                     
$data_index++;                                     
>                                     $frame_index = 1;  
  
>                                 } 
>                             } else { 
>                                 if (($j+1) == $this-
>wave_channels) $frame_index++; 
>                             }                          
  
>                         }                         
>                     }                     
>                     $im = ImageCreate ($width,
(256*$this-
>wave_channels)+1) or die ("Cannot Initialize new GD
image 
stream!"); 
>                     $background_color =
ImageColorAllocate ($im, 
hexdec(substr($this->visual_background_color,1,2)),hexdec
(substr
($this->visual_background_color,3,2)),hexdec(substr($this
-
>visual_background_color,5,2))); 
>                     $cBlack = ImageColorAllocate ($im,
hexdec
(substr($this->visual_background_color,1,2)),hexdec(subst
r($this-
>visual_background_color,3,2)),hexdec(substr($this-
>visual_background_color,5,2))); 
>                     $cGreen = ImageColorAllocate ($im,
hexdec
(substr($this->visual_graph_color,1,2)),hexdec(substr($th
is-
>visual_graph_color,3,2)),hexdec(substr($this-
>visual_graph_color,5,2))); 
>                     $cRed = ImageColorAllocate ($im,
hexdec(substr
($this->visual_border_color,1,2)),hexdec(substr($this-
>visual_border_color,3,2)),hexdec(substr($this-
>visual_border_color,5,2))); 
>                     $cBlue = ImageColorAllocate ($im,
hexdec(substr
($this->visual_grid_color,1,2)),hexdec(substr($this-
>visual_grid_color,3,2)),hexdec(substr($this-
>visual_grid_color,5,2))); 
>                     if ($this->visual_border) 
>                     { 
>                         ImageRectangle
($im,0,0,($width-1),
(256*$this->wave_channels),$cRed); 
>                         for
($i=0;$i<=$this->wave_channels;$i++) 
>                         {                     
>                             ImageLine
($im,1,($i*128)+128,$width,
($i*128)+128,$cRed); 
>                         } 
>                     } 
>                     if ($this->visual_grid) 
>                     { 
>                         for
($i=1;$i<=($width/100*2);$i++) 
>                         { 
>                             ImageLine
($im,$i*50,0,$i*50,
(256*$this->wave_channels),$cBlue); 
>                         }                     
>                     } 
>                      
>                     // this for-loop draws a graph for
every 
channel 
>                      
>                     for
($j=0;$j<sizeof($visualData);$j++) 
>                     { 
>                         $last_x = 1; 
>                         $last_y = 128; 
>                          
>                         // this for-loop draws the
graph itself 
>                          
>                         for
($i=1;$i<sizeof($visualData[$j]);$i++) 
>                         { 
>                             ImageLine
($im,$last_x,($last_y+
($j*256)),$i,($visualData[$j][$i]+($j*256)),$cGreen); 
>                             $last_x = $i; 
>                             $last_y =
$visualData[$j][$i]; 
>                         } 
>                     } 
>                      
>                     // change this to generate JPG or
direct 
output to browser 
>                      
>                     ImagePng ($im,$output); 
>                 } 
>             } 
>             fclose ($file); 
>         } else { 
>             // AudioSample - AudioFile-Object not
initialized! 
>         } 
>     } 
>      
>     // 
************************************************************
*********
*** 
>     // getSampleInfo extracts the attributes of the
AudioFile-
Object 
>     // 
************************************************************
*********
***             
> 
>     function getSampleInfo () 
>     {                 
>         $valid = true; 
> 
>         if
(strstr(strtoupper($this->wave_filename),"MP3")
) 
>         { 
>             $this->mp3info (); 
>         } else { 
>          
>             $this->wave_size = filesize
($this->wave_filename); 
>             if ($this->wave_size > 16) 
>             { 
>                  
>                 $file = fopen
($this->wave_filename,"r"); 
>                 $chunk_id = fgetc($file) . fgetc($file)
. fgetc
($file) . fgetc($
> 
> ----- Original Message ----
> From: chitara1970 <chitara1970...>
> To: php-objects@yahoogroups.com
> Sent: Sunday, December 10, 2006 9:16:42 AM
> Subject: [php-objects] to get the length or
play-time/duration
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   
> 
> 
>     
>             Hi guys!! 
> 
> 
> 
> can anyone please tell me how to convert a audio file
size to 
length. 
> 
> Say I have a file(abc.mpeg) which is 4.6 MB in size
& its length 
is 
> 
> 4.58 minutes. 
> 
> So is there any function in php by which i can get the
length from 
the 
> 
> size of that file?? 
> 
> 
> 
> maybe the sound is so silly but please help me!! 
> 
> 
> 
> actually I need to get the length or play-time of each
song. 
> 
> 
> 
> I kept the file into a foleder & there name is in
the database. 
> 
> 
> 
> Can anyone know any way to get the length of music
file??? 
> 
> 
> 
> Regards  
> 
> 
> 
> 
> 
>     
>   
> 
>     
>     
> 
> 
> 
> 
> <!--
> 
> #ygrp-mlmsg
{font-size:13px;font-family:arial,helvetica,clean,sans-
serif;}
> #ygrp-mlmsg table {font-size:inherit;font:100%;}
> #ygrp-mlmsg select, input, textarea {font:99% 
arial,helvetica,clean,sans-serif;}
> #ygrp-mlmsg pre, code {font:115% monospace;}
> #ygrp-mlmsg * {line-height:1.22em;}
> #ygrp-text{
> font-family:Georgia;
> }
> #ygrp-text p{
> margin:0 0 1em 0;
> }
> #ygrp-tpmsgs{
> font-family:Arial;
> clear:both;
> }
> #ygrp-vitnav{
> padding-top:10px;
> font-family:Verdana;
> font-size:77%;
> margin:0;
> }
> #ygrp-vitnav a{
> padding:0 1px;
> }
> #ygrp-actbar{
> clear:both;
> margin:25px 0;
> white-space:nowrap;
> color:#666;
> text-align:right;
> }
> #ygrp-actbar .left{
> float:left;
> white-space:nowrap;
> }
> .bld{font-weight:bold;}
> #ygrp-grft{
> font-family:Verdana;
> font-size:77%;
> padding:15px 0;
> }
> #ygrp-ft{
> font-family:verdana;
> font-size:77%;
> border-top:1px solid #666;
> padding:5px 0;
> }
> #ygrp-mlmsg #logo{
> padding-bottom:10px;
> }
> 
> #ygrp-vital{
> background-color:#e0ecee;
> margin-bottom:20px;
> padding:2px 0 8px 8px;
> }
> #ygrp-vital #vithd{
> font-size:77%;
> font-family:Verdana;
> font-weight:bold;
> color:#333;
> text-transform:uppercase;
> }
> #ygrp-vital ul{
> padding:0;
> margin:2px 0;
> }
> #ygrp-vital ul li{
> list-style-type:none;
> clear:both;
> border:1px solid #e0ecee;
> }
> #ygrp-vital ul li .ct{
> font-weight:bold;
> color:#ff7900;
> float:right;
> width:2em;
> text-align:right;
> padding-right:.5em;
> }
> #ygrp-vital ul li .cat{
> font-weight:bold;
> }
> #ygrp-vital a {
> text-decoration:none;
> }
> 
> #ygrp-vital a:hover{
> text-decoration:underline;
> }
> 
> #ygrp-sponsor #hd{
> color:#999;
> font-size:77%;
> }
> #ygrp-sponsor #ov{
> padding:6px 13px;
> background-color:#e0ecee;
> margin-bottom:20px;
> }
> #ygrp-sponsor #ov ul{
> padding:0 0 0 8px;
> margin:0;
> }
> #ygrp-sponsor #ov li{
> list-style-type:square;
> padding:6px 0;
> font-size:77%;
> }
> #ygrp-sponsor #ov li a{
> text-decoration:none;
> font-size:130%;
> }
> #ygrp-sponsor #nc {
> background-color:#eee;
> margin-bottom:20px;
> padding:0 8px;
> }
> #ygrp-sponsor .ad{
> padding:8px 0;
> }
> #ygrp-sponsor .ad #hd1{
> font-family:Arial;
> font-weight:bold;
> color:#628c2a;
> font-size:100%;
> line-height:122%;
> }
> #ygrp-sponsor .ad a{
> text-decoration:none;
> }
> #ygrp-sponsor .ad a:hover{
> text-decoration:underline;
> }
> #ygrp-sponsor .ad p{
> margin:0;
> }
> o {font-size:0;}
> .MsoNormal {
> margin:0 0 0 0;
> }
> #ygrp-text tt{
> font-size:120%;
> }
> blockquote{margin:0 0 0 4px;}
> .replbq {margin:4;}
> -->
> 
> 
> 
> 
> 
> 
> 
> 
>  
> 
____________________________________________________________
_________
_______________
> Yahoo! Music Unlimited
> Access over 1 million songs.
> http://music.yahoo.c
om/unlimited
> 
> [Non-text portions of this message have been removed]
>




PHP Data object relational mapping generator
http://www.metastorage.ne
t/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://gro
ups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http:/
/groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:php-objects-digest@yahoogroups.com 
    mailto:php-objects-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )