Commit b89c10a3 authored by Stéphane Crozat's avatar Stéphane Crozat

adding changeAudio for lecture-audio extract player

parent f997fc13
......@@ -25,7 +25,31 @@ function changeDiv(id, max, done) {
var root = getXmlFile(fileName).documentElement;
var div = document.getElementById(id);
div.textContent = null;
div.appendChild(document.adoptNode(root));
div.appendChild(document.adoptNode(root));
}
function changeAudio(id, url, name, max, done, autoplay) {
var div = document.getElementById(id);
var fileNumber = getNumber(max,done);
var fileName = url + "/" + name + "_" + zeroFormat(fileNumber,3) + ".mp3"
//Retrieve XML root node from file
var audio = document.createElement("audio");
audio.setAttribute("src",fileName);
audio.setAttribute("controls","");
if (autoplay) { audio.setAttribute("autoplay","") };
div.textContent = null;
div.appendChild(document.adoptNode(audio));
}
function zeroFormat(number,digit) {
/* add Zero digits before ,number if necessary */
/* temp version works only if digit=3 */
if (digit==3) {
if (number<10) return "00" + number;
if (number<100) return "0" + number;
return number;
}
return number;
}
function dice(max) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment