1.11M Members

toggle on/off embedded music

 
0
 

I'm trying to get this code to toggle between innerhtml - turn off embedded music. But it doesn't seem to be firing?

The html in question:

<span id="music">
<embed src="http://thewalshgroup.ca/dev/the-nest/music/12_full_prom-night_0132.mp3"autostart="true" loop="true"
width="2" height="0" id="player"> <noembed> <bgsound src="http://thewalshgroup.ca/dev/the-nest/music/12_full_prom-night_0132.mp3"> </noembed>
</embed> 
</span>

and the jquery function:

$(document).ready(function() {

var playing = true;

$('#music_control').click(function() {

      if (playing == false) {
       alert('false');
          $('music').html("<embed src='http://site.com/dev/link/music/12_full_prom-night_0132.mp3'autostart='true' loop='true'
width='2' height='0' id='player'> <noembed> <bgsound src='http://site.com/dev/link/music/12_full_prom-night_0132.mp3'> </noembed>");
          playing = true;
          $("#music_control").text("MUSIC ON");

      } else if (playing == true) {
       alert('true');
         $('music').html("<embed src='http://site.com/dev/link/music/12_full_prom-night_0132.mp3'autostart='false' loop='true'
width='2' height='0' id='player'> <noembed> <bgsound src='http://site.com/dev/link/music/12_full_prom-night_0132.mp3'> </noembed>");

        playing = false;
        $("#music_control").text("MUSIC OFF");
      }

  });
}); 
Question Self-Answered as of 1 Year Ago
 
0
 

Care to share your solution to help others?

 
1
 

Sure! Sorry about that!

For the jquery, I put:

$(document).ready(function() {

var playing = true;


$("#music_control").click(function(){


        if (playing == false) {
        playing = true;

          $('#music').html(" <embed src='http://url.com/dev/music/12_full_prom-night_0132.mp3' autostart='true' loop='true' width='2' height='0' id='player'> ");




          $("#music_control").text("MUSIC OFF"); 



      } else if (playing == true) {
      playing = false;

         $('#music').html("<!-- asdf -->");


        $("#music_control").text("MUSIC ON"); 

      } 


  }); 



}); 

and in the html I had a link control and the div to switch:

<a href="#" id="music_control" class="">MUSIC OFF</a>


<div id="music">
    <embed src="http://url.com/dev/music/12_full_prom-night_0132.mp3"autostart="true" loop="true"
width="2" height="0" id="player">
    </embed> 
</div>
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article