I have a site with an flash player.
This codes servers me the flash player stored in player_codes.php:
<script language="javascript" type="text/javascript" src="songs_related/flashmp3player/swfobject.js" ></script>
<!-- Div that contains player. -->
<div id="player">
<h1>No flash player!</h1>
<p>It looks like you don't have flash player installed. <a href="http://www.macromedia.com/go/getflashplayer" >Click here</a> to go to Macromedia download page.</p>
</div>
<!-- Script that embeds player. -->
<script language="javascript" type="text/javascript">
var so = new SWFObject("songs_related/flashmp3player/flashmp3player.swf", "player", "290", "247", "9"); // Location of swf file. You can change player width and height here (using pixels or percents).
so.addParam("quality", "high");
so.addVariable("content_path","songs_related/uploads"); // Location of a folder with mp3 files (relative to php script).
so.addVariable("color_path","songs_related/flashmp3player/default.xml"); // Location of xml file with color settings.
so.addVariable("script_path","songs_related/flashmp3player/flashmp3player.php");
// Location of php script.
so.write("player");
</script>
This is how i include the player backend
<div id="main_music_player_for_the_site">
<?php include_once('player_codes.php'); ?>
</div>
If you go to this link here and press play on any song in the list the following happens:
- I send a request to backend and set the song.
- Confirmation comes to me.
- I load the player from the player_codes.php (given above)
But when step 3 happens it refreshes! and gets stuck
It should not refersh its not refreshing in my localhost also.
Here is my JS that does the work (called after i get a response in step 2)
function callBackForLoadSong(data)
{
//alert(data);
if(data == "failed")
{
alert("Song requres you to login. Its easy to create an account! We will take you to the login page after you press ok");
window.location.replace(REDIRECT);
}
else
{
//alert("s");
$("#main_music_player_for_the_site").text("refreshing player...");
$("#main_music_player_for_the_site").load("player_codes.php");
}
}
Main thing thats bugging me is why is the page getting refreshed??? and getting stuck
You have the same HREF for every play buttons. Looks like your onClick event loads the songs?
You should have :
Instead of :
Right now, you tell javascript to load your song with the onClick event and you tell the browser to go to a different URL using HREF. javascript:void(0) will prevent the browser to execute the HREF.