demo.basic.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at https://github.com/JamesHeinrich/getID3 //
  5. // or https://www.getid3.org //
  6. // or http://getid3.sourceforge.net //
  7. // //
  8. // /demo/demo.basic.php - part of getID3() //
  9. // Sample script showing most basic use of getID3() //
  10. // see readme.txt for more details //
  11. // ///
  12. /////////////////////////////////////////////////////////////////
  13. die('For security reasons, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in demos/'.basename(__FILE__));
  14. // include getID3() library (can be in a different directory if full path is specified)
  15. require_once('../getid3/getid3.php');
  16. // Initialize getID3 engine
  17. $getID3 = new getID3;
  18. // Analyze file and store returned data in $ThisFileInfo
  19. $ThisFileInfo = $getID3->analyze($filename);
  20. /*
  21. Optional: copies data from all subarrays of [tags] into [comments] so
  22. metadata is all available in one location for all tag formats
  23. metainformation is always available under [tags] even if this is not called
  24. */
  25. $getID3->CopyTagsToComments($ThisFileInfo);
  26. /*
  27. Output desired information in whatever format you want
  28. Note: all entries in [comments] or [tags] are arrays of strings
  29. See structure.txt for information on what information is available where
  30. or check out the output of /demos/demo.browse.php for a particular file
  31. to see the full detail of what information is returned where in the array
  32. Note: all array keys may not always exist, you may want to check with isset()
  33. or empty() before deciding what to output
  34. */
  35. //echo $ThisFileInfo['comments_html']['artist'][0]; // artist from any/all available tag formats
  36. //echo $ThisFileInfo['tags']['id3v2']['title'][0]; // title from ID3v2
  37. //echo $ThisFileInfo['audio']['bitrate']; // audio bitrate
  38. //echo $ThisFileInfo['playtime_string']; // playtime in minutes:seconds, formatted string
  39. /* if you want to see all the tag data (from all tag formats), uncomment this line: */
  40. //echo '<pre>'.htmlentities(print_r($ThisFileInfo['comments'], true), ENT_SUBSTITUTE).'</pre>';
  41. /* if you want to see ALL the output, uncomment this line: */
  42. //echo '<pre>'.htmlentities(print_r($ThisFileInfo, true), ENT_SUBSTITUTE).'</pre>';