Playing external audio files

Sep 02, 2020

Hello

I would like to play an audio file that is not imported into an articulate lesson but is at a specific URL somewhere else. How could I go about doing that (or is it at all possible)?

Second (I would like to play that file in a loop a specific number of times). 

I would prefer to do this inside an articulate file.

Is ay of that possible?

Thank you very much.

3 Replies
Brian Dennis

MP3 are stream-able formats so you could try using a Web Object. Another option is creating a small bit of HTML <audio> tag that references the MP3. Test within a browser, then point the Web Object to the html page, which would need to be hosted on a web server. Newer SL utilize embed.ly which might be a simpler solution.

OWEN HOLT

Execute JavaScript at timeline start:

//load the scripts dynamically into the head of the document
function add_line() {
    var line = document.createElement("audio");
    var head=document.getElementsByTagName('body')[0];
    line.type = "audio/mp3";
    line.src="";
    line.id="bgSong" ;
 line.autoplay = true;
 line.loop = true;
    head.appendChild(line);
}

//but we only want to add these once!
if(document.getElementById('bgSong')==null){
 add_line();
var audio = document.getElementById('bgSong');
audio.volume = 0.1;
}

Next, because modern browsers require interaction to play media, add a trigger to some interaction on the page to start playing the music by executing the following JavaScript "when user clicks":

var audio = document.getElementById('bgSong');
audio.src='Your/Musics/Full/URL/Goes/Here.mp3';
audio.load();
audio.play();

 

This discussion is closed. You can start a new discussion or contact Articulate Support.