Results 1 to 5 of 5

Thread: How to read the first 100k of remote mp3 file?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Talking How to read the first 100k of remote mp3 file?

    Hi all . could any one show me how i can read the first 100 k of a remote mp3 file but not the whole file. i be happy if an expert show me how.Thanks

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: How to read the first 100k of remote mp3 file?

    From the manual:

    string fread ( resource handle, int length )

    fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when up to length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
    Use fopen(string filename, string mode), which returns a resource handle, to open the remote file (assuming that such a feature is enabled within your PHP).

    PHP Code:
    $fp fopen('http://remote/file.mp3''r');
    $data fread($fp100 1024); 
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to read the first 100k of remote mp3 file?

    Many thanks for u reply. I am running php on my localhost server . How i know if it is enabled ? could u tell me how to enable it ?

    Furthermore , how i can confirm that the partion of the file is downloaded?where it will be stored? The reason is that i want to use getId3 with that mp3 file and get its tag info.So i be happy if u tell me how i can refrence that partial downloaded file.Thanks

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: How to read the first 100k of remote mp3 file?

    Quote Originally Posted by tony007
    Many thanks for u reply. I am running php on my localhost server . How i know if it is enabled ? could u tell me how to enable it ?
    Just test it and see. To enable it, you'd have to configure your PHP and if you don't know how to do that, you probably don't have access to do so.
    Quote Originally Posted by tony007
    Furthermore , how i can confirm that the partion of the file is downloaded?where it will be stored? The reason is that i want to use getId3 with that mp3 file and get its tag info.So i be happy if u tell me how i can refrence that partial downloaded file.Thanks
    It's stored in $data...
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to read the first 100k of remote mp3 file?

    Quote Originally Posted by kasracer
    Just test it and see. To enable it, you'd have to configure your PHP and if you don't know how to do that, you probably don't have access to do so.

    It's stored in $data...
    Thank u for u reply. I tried it now i get this error :


    Warning: fopen(http://www.remotesite.com/song.mp3) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in \getid3\remote3.php on line 5

    Fatal error: Call to a member function analyze() on a non-object in \getid3\remote3.php on line 13



    Bold parts are line 5 and 11
    Code:
    <?
    
    if ($fp1 = fopen('http://www.remotesite.com/song.mp3', 'rb')) { 
      $tempname = tempnam('/tmp', 'foo'); 
      if ($fp2 = fopen($tempname, 'wb')) { 
        fwrite($fp2, fread($fp, 102400)); 
        fclose($fp2); 
      } 
      fclose($fp1); 
    } 
    $getID3->analyze($tempname);  line 13th
    
    
    
    ?>
    I even tried this but i got error again:

    Code:
    <?
    $fp = fopen('http://www.remoteserver.com/1.mp3', 'r'); 
    $data = fread($fp, 100 * 1024); 
    
    $getID3->analyze($data); 
    
    ?>
    Error:

    Code:
    Warning: fopen(http://www.remoteserver.com/1.mp3 ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in \getid3\remote3.php on line 6
    
    Warning: fread(): supplied argument is not a valid stream resource in \getid3\remote3.php on line 7
    
    Fatal error: Call to a member function analyze() on a non-object in \getid3\remote3.php on line 9
    I be happy if u let me know how to fix it.thanks
    Last edited by tony007; Apr 28th, 2006 at 09:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width