Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 18th, 2024, 5:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: HTML5/JavaScript-play audio sound
PostPosted: March 30th, 2019, 4:52 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi,

To stop playing a sound in HTML5, is there a stop() function or do you use pause()?


Code:

S1 = new Audio('abc.MP3');
S2 = new Audio('def.MP3');
S1.play()
S1.pause()

S2.play()
S2.pause()
             

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: HTML5/JavaScript-play audio sound
PostPosted: March 31st, 2019, 9:56 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Just pause().

See https://www.w3schools.com/jsref/dom_obj_audio.asp

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: HTML5/JavaScript-play audio sound
PostPosted: March 31st, 2019, 1:37 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Update: found the answer: S1.currentTime = 0; and S2.currentTime = 0;, each time before play(). This fixed the gap.

I'm getting a small gap (silence) in the playback when repeatedly using play/pause/play. The MP3's are 30 second loops. I'm guessing that the gap occurs when the end of the loop is reached, although I thought that I recorded these with a smooth transition.

Is there a way to pause and then immediately return the loop to the beginning so that the next time it is played, it is playing from the beginning and not resuming from the paused location?

30 seconds is longer than the sound will ever need to play, so if I can always play a paused sound from the beginning, it should solve any looping gap problem (if this is what is occurring).

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group