function Mscale() {
document.getElementById("scale").src=scales[0]
}
function Hmscale() {
document.getElementById("scale").src=scales[1]
}
function Nmscale() {
document.getElementById("scale").src=scales[2]
}
function Mmscale() {
document.getElementById("scale").src=scales[3]
}
function Chrscale() {
document.getElementById("scale").src=scales[4]
}
Do you get any error messages?
What browser(s) did you try with.
Dunno if it is a typo when you pasted the code, but your second example has double-quotes within a double-quoted string, which is a mistake - either use single-quotes for one set, or else backslash-escape the internal set.
No I'm not looking for a playlist, just some way to have one embedded element for which the source changes by clicking different links. I can't figure out why the code above didn't work so any suggestions would be welcome. THe sound files aren't songs, just short sound clips.
A song is also a sound clip, whether it is short or long.
You probably need to do this in HTML5 with the audio element. Then, I guess you need some scripting so that onclick, the current song stops playing, the src"" (or <source>) will be changed and then trigger the play() method agiain.
A song is also a sound clip, whether it is short or long.
You probably need to do this in HTML5 with the audio element. Then, I guess you need some scripting so that onclick, the current song stops playing, the src"" (or <source>) will be changed and then trigger the play() method agiain.
That should work fine
Christophe
I need someone to help me by suggesting specific HTML and javascript I can use? could someone in this post please provide some code suggestions whether it's HTML5 or CSS or Javascript or whatever. Any suggestion would be appreciated
This small audioplayer is tested in Chrome and IE9. It didn't work in Firefox, but that probably has something to do with MIME types (not a lot of time to check it out)
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<title>HTML 5 audio player demo</title>
<script>
$(document).ready(function() {
$('button').click(function() {
var music = document.getElementById('audiotag1');
if ( music.paused ) {
music.play();
$(this).text('Pause');
} else {
music.pause();
$(this).text('Play');
}
});
$('.song').click(function() {
var path = $(this).find('span').text();
$('audio').attr('src', path);
var music = document.getElementById('audiotag1');
music.play();
$('button').text('Pause');
});
});
</script>
<style>
.song:hover {
cursor: pointer;
}
</style>
</head>
<body>
<audio id="audiotag1" src="/path/to/first/song.mp3" preload="auto"></audio>
<button>Play</button>
<div class="song">
First song
<span style="visibility:hidden;">/path/to/first/song.mp3</span>
</div>
<div class="song">
Second song
<span style="visibility:hidden;">/path/to/second/song.mp3</span>
</div>
</body>
</html>
Bookmarks