Jump to content

Embedding Flash in PHP


hellonoko

Recommended Posts

My below code uses a bit of Flash to create a mini mp3 player button for each mp3 in a directory.

 

As it stands there are 3 test files in the directory but for some reason only the first flash player button is displayed and not the name of the file.

 

So for some reason the loop is failing after the embedded flash.

 

Any ideas?

 

<?php

   	$arr = array();

   	foreach (glob("*.*") as $filename) 
   	{
      	$arr[$filename] = filemtime($filename);

   	}



   	arsort($arr);
   	echo "<br>";

   	foreach($arr as $key => $value) 
{
    	
	if ( $key !== "filelist3.php")
	{

		echo '<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">';
         	echo '<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>';

         	echo '<img src="noflash.gif" width="17" height="17" alt="" />';
         	echo "$key<br>";
	}
   	} 
?>

Link to comment
Share on other sites

echo '<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/'.$key.'" width="17" height="17">';
        	echo '<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/'.$key.'"/>';

 

I think that's what thorpe meant.

 

Edit: Or not

Link to comment
Share on other sites

full code:

 

<?php

   	$arr = array();

   	foreach (glob("*.*") as $filename) 
   	{
      	$arr[$filename] = filemtime($filename);
    	//echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>";    
   	}

   ///
   
   //asort($arr);
   //echo "<br>";

//foreach($arr as $key => $value) 
   	//{
    //	echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>";
   	//}

///

   	arsort($arr);
   	echo "<br>";

   	foreach($arr as $key => $value) 
{
    	
	if ( $key !== "filelist3.php")
	{

		echo "<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">";
         	echo "<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>";

         	echo "<img src="noflash.gif" width="17" height="17" alt="" />";
         	echo "$key<br>";
	}
   	} 
?>

Link to comment
Share on other sites

Escaped the quotes and does not have any errors but still only displays one song. And not the first one.

 

www.sharingizcaring.com/REPOSITORY/filelist3.php

 

<?php

   	$arr = array();

   	foreach (glob("*.*") as $filename) 
   	{
      	$arr[$filename] = filemtime($filename);
    	//echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>";    
   	}

   ///
   
   //asort($arr);
   //echo "<br>";

//foreach($arr as $key => $value) 
   	//{
    //	echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>";
   	//}

///

   	arsort($arr);
   	echo "<br>";

   	foreach($arr as $key => $value) 
{
    	
	if ( $key !== "filelist3.php")
	{


		echo "<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\" width=\"17\" height=\"17\">";
         	echo "<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\"/>";

         	echo "<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />";
         	echo "$key<br>";
	}
   	} 
?>

 

Tried it with soft quotes on the outside '<object.....

 

And that does not break the loop but breaks the Flash. That is how it is now.

Link to comment
Share on other sites

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.