Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Play sound on click

    hi.

    this is probably fairly simple...

    i am using in-page javascript on some of my pages to play a sound on clicking an image which loops a backing track to practise scales / lead guitar to.

    here's the script:

    Code:
    <script language="javascript" type="text/javascript">
     function playSound(soundfile) {
     document.getElementById("dummy").innerHTML=
     "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"true\" />";
     }
     </script>
    <span id="dummy"></span>

    and here's how i'm calling it for each image / mp3:

    Code:
    <p><a title="Play file" href="#" onclick="playSound('mp3 url');"><img title="Play" src="play button url" alt="Play" width="48" height="48" /></a>  Blues in <strong>C</strong> : backing for lead melody. Chords: C,F, G</p>
    my first question - the track isn't looping - is there something wrong with the script?

    my second question - how do i extend the function so that on clicking the png to play the file it is swapped for another - stop button - which stops the loop when clicked.

    many thanks, jan

  • #2
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any takers?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •