Jump to content

Recommended Posts

Hi I have an .mp3 file on my host that has a title, artist, and album artwork. How can I capture this in PHP so then I can go to my iPhone app and use what the PHP file captured?

<?php
    
    function fooFucker($url) {
        $a = join('/', array_map('urlencode', explode('/', $url)));
        return str_replace('+', '%20', $a);
    }
    
    $SongsFolder = "songs";
    
    header("Content-Type: audio/x-mpegurl");
    
    $body = '';
    
    $Songs = glob($SongsFolder."/*.mp3");
    shuffle($Songs);
    $first = 0;
    
    foreach($Songs as $Song)
    {
        $SongPath = pathinfo($Song);
        if ($first != 0) {
            $body .= "\n";
        }
        $first = 1;
        $body .= "http://".$_SERVER['HTTP_HOST'].fooFucker(dirname($_SERVER['PHP_SELF']))."/".fooFucker($SongsFolder)."/".fooFucker($SongPath['basename']);
    }
    header('Content-Length: ' . strlen($body));
    echo $body;
?>
Link to comment
https://forums.phpfreaks.com/topic/285081-title-artist-and-album-artwork-in-php/
Share on other sites

If you want to use PHP to extract the ID3 info for an MP3, then I would highly suggest using getID3().

 

Will this install to GoDaddy shared hosting? Sorry I'm more of an iPhone app developer and trying learn this PHP stuff. I feel like my PHP code I'm using above will not be able to get the title, artist, and album artwork because of the way it's set up. You have any examples on how I can go about doing this?

getID3 is a PHP function. You can install it locally through composer:

https://packagist.org/packages/james-heinrich/getid3

 

Or you can simply download it as a .zip and extract it in your project root:

https://github.com/JamesHeinrich/getID3/archive/master.zip

Edited by ignace
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.