0

This simple code changes sounds in firefox, IE, safari, and chrome but will not switch in Opera. Any thoughts?

<div id="playlist"style="position: absolute; z-index:10001; top: 0px; width: 100%; height: 100%;">

    <button id="one" onclick="song1();">Mello</button>        
    <button id="two" onclick="song2();">Its Time</button>         
    <button id="three" onclick="song3();">Its on now</button>

<div id="hideme" style="width: 392px">
    <audio id ="audio" controls loop>
        <source id="oggSource" src="sounds/Starset.ogg" type="audio/ogg">
        <source id="mp3Source" src="sounds/Starset.mp3" type="audio/mpeg">  
        Your browser does not support the audio element.
    </audio>     
</div>
</div>

Edited by Dani: Formatting fixed

1
Contributor
1
Reply
18
Views
3 Years
Discussion Span
Last Post by StephenopolousINC
0

Sorry I forgot to post the Javascript:

<script>

var song1 = function () {
document.getElementById('audio').src = 'sounds/Starset.ogg';
document.getElementById('audio').src = 'sounds/Starset.mp3';


var audioEl = document.getElementById("audio");

            audioEl.load();
            audioEl.play();
}
var song2 = function() {
document.getElementById('audio').src = 'sounds/jt.ogg';
document.getElementById('audio').src = 'sounds/jt.mp3';

var audioEl = document.getElementById("audio");

            audioEl.load();
            audioEl.play();
}
var song3 = function() {
document.getElementById('audio').src = 'sounds/dtd.ogg';
document.getElementById('audio').src = 'sounds/dtd.mp3';

var audioEl = document.getElementById("audio");

            audioEl.load();
            audioEl.play();
}

</script>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.