ziedinjsh Posted September 24, 2009 Report Share Posted September 24, 2009 (edited) index.php: <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type='text/javascript' src='misc/swfobject.js'></script> <link rel="stylesheet" type="text/css" href="misc/style.css"> <title>MP3 ::: producentiem.lv</title> </head> <body> <center><div id='preview'>This div will be replaced</div> <script type='text/javascript'> var s1 = new SWFObject('misc/player.swf','player','470','350','9','#000000'); s1.addParam('allowfullscreen','false'); s1.addParam('allowscriptaccess','always'); s1.addParam('wmode','opaque'); s1.addParam('flashvars','image=http://producentiem.lv/images/logo.png&file=http://www.producentiem.lv/mp3/playlist.php&fullscreen=false'); s1.write('preview'); </script> </center> </body> </html> Playlist.php: <?php /* * This is a sample file that reads through a directory, filters the mp3/jpg/flv * files and builds a playlist from it. After looking through this file, you'll * probably 'get the idea' and'll be able to setup your own directory. * */ // set this to a creator name $creator = "Myself"; // search for mp3 files. set this to '.flv' or '.jpg' for the other scripts $filter = ".mp3"; // path to the directory you want to scan // "./" = current directory $directory = "./mp3"; // URL to files $url = "http://mp3.producentiem.lv/mp3/"; /////////////////////////// no user configuration variables below this \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // read through the directory and filter files to an array @$d = dir($directory); if ($d) { while($entry = $d->read()) { $ps = strpos(strtolower($entry), $filter); if (!($ps === false)) { $items[$entry]['mtime'] = filemtime($entry); } } $d->close(); arsort($items); } // the playlist is built in an xspf format // first, we'll add an xml header and the opening tags... echo "<?xml version='1.0' encoding='utf-8'?>\n"; echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n"; echo " <title>Sample PHP Generated Playlist</title>\n"; echo " <info>" . $url . "</info>\n"; echo " <trackList>\n"; // ...then we loop through the array... foreach($items as $key => $value){ $title = substr($key, 0, strlen($key) - 4); echo " <track>\n"; echo " <creator>" . $creator . "</creator>\n"; echo " <title>" . $title . "</title>\n"; echo " <location>" . $url . '/' . $key . "</location>\n"; echo " <info>" . $url . "</info>\n"; echo " </track>\n"; } // ...and last we add the closing tags echo " </trackList>\n"; echo "</playlist>\n"; /* * That's it! You can feed this playlist to the SWF by setting this as it's 'file' * parameter in your HTML page. */ ?> Playeris man parādās, bet bez apakšējās playista un rāda ERROR #2048 Edited September 24, 2009 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
marcis Posted September 24, 2009 Report Share Posted September 24, 2009 Atver xmlu bourzerī un apskaties vai viņš tiek uzģenerēts pareizs un vai vispār tiek uzģenerēts. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 playlist.xml arī jābūt? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 lai atvērtu xml tad jau jābūt xml failam.. man nav.. un ja atveru playlist.php man rādas: Warning: arsort() expects parameter 1 to be array, null given in /home/produc/public_html/mp3/playlist.php on line 38 http://mp3.producentiem.lv/mp3/ Warning: Invalid argument supplied for foreach() in /home/produc/public_html/mp3/playlist.php on line 51 Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 24, 2009 Report Share Posted September 24, 2009 Pirms 38. rindiņas tātad $items nav ticis definēts - tātad ne reizi nav bijuši nosacījumi, lai izpildītos: $items[$entry]['mtime'] = filemtime($entry); 51. rindiņa - tieši tas pats iemesls. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 (edited) es īsti nesapratu par to 51 rindiņu.. ieliku pirms 38 rindiņas ko teici, bet tagad rāda šādi: Warning: filemtime() [function.filemtime]: stat failed for 01-gregor_tresher-a_thousand_nights_(dubfire_quiet_storm_remix)-scratch.mp3 in /home/produc/public_html/mp3/playlist.php on line 34 http://mp3.producentiem.lv/mp3/ Myself http://mp3.producentiem.lv/mp3//0 http://mp3.producentiem.lv/mp3/ Myself http://mp3.producentiem.lv/mp3//01-gregor_tresher-a_thousand_nights_(dubfire_quiet_storm_remix)-scratch.mp3 http://mp3.producentiem.lv/mp3/ Liakam jau to tur navajadzēja likt.. tātad kā jānodefinē $items? Edited September 24, 2009 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 24, 2009 Report Share Posted September 24, 2009 Nē, neko nekur likt es neteicu. Lūk ir koda fragments: if ($d) { while($entry = $d->read()) { $ps = strpos(strtolower($entry), $filter); if (!($ps === false)) { $items[$entry]['mtime'] = filemtime($entry); } } $d->close(); arsort($items); } ja $d->read() ne reizi neizpildās, tad arī nav iespējas pārbaudīt nākamo lietu - if (!($ps === false)). Tikai ja izpildās arī if (!($ps === false)), vispār tiek izveidots tāds $items. Starp citu... Kā Tev šķiet, ko tieši šis salīdzinājums pārbauda: if (!($ps === false)) ? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 Jagodīgi es nezinu.. kaut ko pārbauda ir vai nav ja nav tad nekā arī nav ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.