Jump to content

Fijiannn

Members
  • Posts

    23
  • Joined

  • Last visited

About Fijiannn

  • Birthday 03/01/1996

Profile Information

  • Gender
    Male
  • Location
    Sacramento, CA
  • Age
    17

Fijiannn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi I have this code below. I'm using getid3 to get the file name, artist, and title of the songs I have in the $SongsFolder. What I'm trying to do is make the artist and title accessible so I can get this info in my iPhone app for example. I figure I would replace echo with something else but how would I properly do that? I'm really new to PHP and more of an iPhone app developer so a little help would be nice. <?php require_once("getid3/getid3.php"); $getID3 = new getID3; $SongsFolder = "Songs"; $Songs = glob($SongsFolder."/*.mp3"); foreach ($Songs as $Song) { set_time_limit(30); $ThisFileInfo = $getID3->analyze($Song); getid3_lib::CopyTagsToComments($ThisFileInfo); echo 'File name: '.$ThisFileInfo['filenamepath'].'<br>'; echo 'Artist: '.(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<BR>', $ThisFileInfo['comments_html']['artist']) : ' ').'<br>'; echo 'Title: '.(!empty($ThisFileInfo['comments_html']['title']) ? implode('<BR>', $ThisFileInfo['comments_html']['title']) : ' ').'<br>'; } ?>
  2. Your code is good but it just doesn't play my music anymore.
  3. My orginal code already did that!
  4. So with a little editing on the code below. I got it to output the correct link to a song but the thing is my music isn't playing so I can't tell if link the console outputted is correct with the song playing. What's wrong? <?php function myFunction($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"); if (count($songs) == 0) { echo "Error - no songs found"; exit(); } shuffle($songs); $body .= "http://" . $_SERVER['HTTP_HOST'].myFunction(dirname($_SERVER['PHP_SELF']))."/".myFunction($SongsFolder).$songs[0]; header('Content-Length: ' . strlen($body)); echo $body; ?>
  5. Well I replaced my code with the code above. <?php $songsfolder = "songs"; header("Content-Type: audio/x-mpegurl"); $body = ''; $songs = glob($songsfolder."/*.mp3"); if (count($songs) == 0) { echo "Error - no songs found"; exit(); } shuffle($songs); $body .= "http://" . $_SERVER['HTTP_HOST'] . $songs[0]; header('Content-Length: ' . strlen($body)); echo $body; ?> It does give me a link "http://virsamusic.comsongs/21 Bharat Mata Ki Jai.mp3 " I messed up link, not linking to the actual song but it does get the name of the .mp3. Also, it's suppose to stream music and my music isn't playing. What could be wrong now?
  6. Very good explanation man! See I just needed it explained like this.
  7. I'll try it when I get home but I wanted to make the link that it outputted a variable so I can call that variable in my iPhone app for something in my code.
  8. So this code above will give me the link to the chosen song after shuffle? That's what I don't get.
  9. Hmmm, I'm kinda new to this PHP stuff. Got an example?
  10. When I echo $body it echo's the link to every mp3 song in my folder called "songs" ($SongsFolder) when all I want is for the shuffle() to just shuffle, choose a link to a song then output the link to the song it chose.
  11. Hi in my code below, echo $body; outputs the link to every song in my $SongsFolder. How can I make it echo only one link and that link is the song the $Shuffle chose? I know I have array but is there a way to get around it? Anything I should change up? <?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; ?>
  12. Okay well, how can I do it using that?
  13. That's not, the actual player is choosing a different song then the metadata is.
  14. Why would I want to make an array of every song? I have over a 400+ songs in the folder with mp3 in it.
  15. So in my code below I have a script where it shuffles through .mp3 in a folder. How can I make the line below know which song the shuffle() has picked? $ThisFileInfo = $getID3->analyze($Songs[0]); <?php require_once('/home/manveers94/public_html/getID3-1.9.7/getid3/getid3.php'); $getID3 = new getID3; 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']); } set_time_limit(30); $ThisFileInfo = $getID3->analyze($Songs[0]); getid3_lib::CopyTagsToComments($ThisFileInfo); $body .= 'File name: '.$ThisFileInfo['filenamepath'].'<br>'; $body .= 'Artist: '.(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<BR>', $ThisFileInfo['comments_html']['artist']) : ' ').'<br>'; $body .= 'Title: '.(!empty($ThisFileInfo['comments_html']['title']) ? implode('<BR>', $ThisFileInfo['comments_html']['title']) : ' ').'<br>'; $body .= 'Bitrate: '.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').'<br>'; $body .= 'Play time: '.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').'<br>'; header('Content-Length: ' . strlen($body)); echo $body; ?>
×
×
  • 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.