Q:

Play audio with javascript (no HTML5 or visible player)

I would like to get a track played when I click on an image link and stopped when I click on it again.
I'm not using HTML5, I'm not using audio tags and I don't want to display any player while the track is playing. 
And this should be as cross browser as possible...
I click, I hear the track, I click again and it stops.
Simple enough but too simple I guess because every tutorial I find about this involves HTML5 and its new tags or flash or some colorful player I don't need.
How would I achieve this please?
Pure javascript or Jquery is ok.
I Thank you in advance for you help

A:

Is there a particular reason why you're not using HTML5 audio tag? because you can set  to not show controls and use the same for play/stop with javascript and toggle the image from play to stop if you want.
with jQuery:
you have this image:
<a href="#" id="audioPlayStop" title="stop">
    <img src="images/stop.png" />
</a>

and this invisible audio tag:
<audio id="audio">
<source src="somethingtoplay.mp3" type="audio/mpeg" />
</audio>

var audio = document.getElementById('audio'); // $('#audio') won't work for audio API!
    $('#audioPlayStop').toggle( 

        function () {

            $(this).attr('title', 'play');
            $(this).add('img').attr('src', 'images/play.png');

            audio.pause();

            console.log('Paused');
        }, 
        function () {
            $(this).attr('title', 'stop');
            $(this).add('img').attr('src', 'images/stop.png');

            audio.play();           

            console.log('Play started');
        } //function
    );

This script actually pauses instead of stopping. But you can figure out how to stop it knowing that you can stop it with 
    audio.src = '';
    audio.load(); // load nothing, so it stops (there's no stop() in audio API)

