Jump to content

Fijiannn

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by Fijiannn

  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; ?>
  16. I tried looping and getting these errors. Warning: pathinfo() expects parameter 1 to be string, array given in /home/manveers94/public_html/yee/Test.php on line 16 Notice: Undefined index: filenamepath in /home/manveers94/public_html/yee/Test.php on line 25 <?php ini_set('display_errors',1); ini_set('display_startup_errors',1); ini_set('output_buffering','Off'); error_reporting(-1); require_once('/home/manveers94/public_html/getID3-1.9.7/getid3/getid3.php'); $getID3 = new getID3; $SongsFolder = "songs"; $file = glob($SongsFolder."/*.mp3"); foreach($file as $SongPath) { $SongPath = pathinfo($file); } // $file = 'Song.mp3' set_time_limit(30); $ThisFileInfo = $getID3->analyze($SongPath); 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>'; echo 'Bitrate: '.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').'<br>'; echo 'Play time: '.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').'<br>'; ?>
  17. Hi I have this code below. What I'm trying to do below is access .mp3 songs that are in my folder called "songs" When I do this code it doesn't show anything for the Artist, Title or anything anymore. Why is that? <?php require_once('/home/manveers94/public_html/getID3-1.9.7/getid3/getid3.php'); $getID3 = new getID3; $SongsFolder = "songs"; $file = glob($SongsFolder."/*.mp3"); // $file = 'Song.mp3' set_time_limit(30); $ThisFileInfo = $getID3->analyze($file); 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>'; echo 'Bitrate: '.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').'<br>'; echo 'Play time: '.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').'<br>'; ?>
  18. 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?
  19. How could I install what it needs on a Mac?
  20. 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; ?>
  21. How would you live stream a whole bunch of .mp3 in random order?
  22. None of this seem to work for me. Do you have your own method of shuffling an .m3u file through PHP?
  23. Hi I have an .m3u playlist file on my server, it has links to different songs on my server. The .m3u playlist streams all the music. The thing I want the .m3u file to do is shuffle the music instead of going in the same order. I've been using this method to do it but it doesn't work. Any other ways or something wrong with my code? <?php $playlist = “/DONTFUCKWITHME/playlist.m3u"; if ($_SERVER['PATH_INFO'] == "/playlist.m3u") { # This a request for the actual playlist. playlist(); } else { # Fall through to end of script and display # the player HTML. } function playlist() { header("Content-type: audio/mpeg"); # Needed for PHP versions OLDER than 4.2.0 only. # If your host still has PHP older than 4.2.0, shame on them. # Find a better web host. srand(make_seed()); # Fetch our list of songs from a file. $songs = file($playlist); shuffle($songs); # Now output the URLs in random order. foreach ($songs as $song) { # Remove newline and any other leading and trailing # whitespace from URL of song. $song = trim($song); echo "$song\n"; } # Now exit before any HTML is produced. exit(0); } # Needed only for very old versions of PHP, # see srand call earlier. function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } ?> <html> <head> <title>MP3s Playing in Random Order</title> </head> <body> <h1 align="center">MP3s Playing in Random Order</h1> <embed src="/examples/randomsongs.php/playlist.m3u" width="0" height="0" autostart="true" type="audio/mpeg" loop="true"/> </body> </html>
×
×
  • 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.