PDA

View Full Version : Non-looping audio playback



Vizionz
10-10-2016, 11:03 PM
1) Script Title: HTML5 background audio player

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/html5audioplayer.htm

3) Describe problem:

Great script - thanks. But I do need the audio file to play just the once and not automatically loop back to the beginning once the track has finished its first full cycle. Can somebody advise me how I can stop the track from looping please?

Many thanks in advance

jscheuer1
10-11-2016, 01:56 PM
I bet bet it's the loop setting in the script itself. Using a text only editor like NotePad, open the bgaudioplayer.js file. At the top we see:


/* HTML5 background audio player
* Created: Jan 31st, 2012 by DynamicDrive.com. This notice must stay intact for usage
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/

jQuery.noConflict()

var bgaudioplayer = (function($){

var audio5support = !!document.createElement('audio').canPlayType
var d_setting = {autoplay:true, loop:true, persistTimeLine:false, volume:0.5, volumelevels:10}

Notice the highlighted line and the red part in it. Simply remove the red part and that should prevent the audio from looping:


/* HTML5 background audio player
* Created: Jan 31st, 2012 by DynamicDrive.com. This notice must stay intact for usage
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/

jQuery.noConflict()

var bgaudioplayer = (function($){

var audio5support = !!document.createElement('audio').canPlayType
var d_setting = {autoplay:true, persistTimeLine:false, volume:0.5, volumelevels:10}

Save and use that version of the file.

The browser cache may need to be cleared and/or the page reloaded to see changes.

Vizionz
10-11-2016, 04:45 PM
You're a star, jscheur1!!!!!!! Silly me forgot to even look in there! I have got so used to having the audio files called and controlling the loop, controls etc. from with an additional javascript setting within the html page where you call the audio up. Works a treat and saved me loads of work locating, installing and testing the alternatives that do use that method. Thank you so much. :)