play sounds in HTML5

Pi Digital sean at pidigital.co.uk
Wed May 15 20:56:24 EDT 2019


Hi again Alain

What you are talking about I think is known as a form of Dynamic HTML. Basically you use LiveCode to build your list of audio files (put the files into tFileList) and choose one (random or picked by the user via a mobilePick...) then replace out the source file pointer (<source src= ...) in the html file. 

Because you will not be able to write over the original html file included with your app package you will want to duplicate the contents of the html folder into the (specialFolderPath) “Documents” folder. If you are downloading additional audio have these stored directly into Documents/html/audio/. 

Once you’ve changed the html file you can either refresh the page or set the htmltext of the browser to the contents of the updated html file (which is the best option. 

Sean Cole
Pi Digital Prod Ltd

> On 15 May 2019, at 21:44, Alain Vezina via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Thanks Sean,
> 
> You did not misunderstand my request.
> 
> You make me go one step forward : now I can call a sound to be played from a folder where there are several other sound.
> 
> Now, how can I played a sound chosen by random your chosen by the user; in other words, how can I replace "piano-melody.wav" by the name of the chosen sound, never knowing wich sound will be chosen by the user or by a random procedure ? How my program can write in an HTML file, considering there is a list of all the soud files including the extention .WAV or .MP3 or another one?
> 
> Regards
> 
> Alain
> 
> 
>> Le 14 mai 2019 à 17:02, Pi Digital via use-livecode <use-livecode at lists.runrev.com> a écrit :
>> 
>> Hi Alain
>> 
>> The key here is in the line
>> 
>> <source src="piano-melody.wav" type="audio/wav">
>> 
>> Instead of just piano-melody.wav you would put in the whole path or relative path to the file. Example, if your file structure has a folder called ‘html’ containing your html file and then another folder called ‘audio’ which contains all your audio files including one called piano-melody.wav then the code would read
>> 
>> <source src="/audio/piano-melody.wav" type="audio/wav">
>> 
>> This points to the file in a relative path to the html file itself. 
>> 
>> Does this help or have I misunderstood your request?
>> 
>> Regards
>> 
>> Sean Cole
>> Pi Digital Prod Ltd
>> 
>>> On 14 May 2019, at 20:52, Alain Vezina via use-livecode <use-livecode at lists.runrev.com> wrote:
>>> 
>>> Hi all,
>>> 
>>> Is there somebody who knows how to play one sound after another using the path of each sound.
>>> 
>>> I read the lesson [ How do I play sound files in HTML5? ] where I have to type the name the sound in the HTML file and to put the sound file into the standalone folder.
>>> 
>>> You know, I want to use one of my sounds libraries as I did into a standalone for Mac, PC , IOS or Android : you specify once the path of the library and the name of the sound you want to be played. The sounds library is not in the app and every sound has his proper name. So I can play a sound chosen by random  or chosen by the user.
>>> 
>>> Alain Vezina
>>> Logilangue
>>> www.logilangue.com
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list