Playing Soundfiles

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Playing Soundfiles

Post by Joerg Hamacher »

Hi,

I have problems understanding how to play soundfiles from a web page. There is the sound control (#PRIM_SOND) but I do not get it working.
Does anybody have an example how I can start to play a single mp3-file and maybe even how to load a playlist and play them one after the other?
By the way: how do I have to address the files? Can I access them by using my local directory paths or do they have to be defined especially for the web server?

#PRIM_SOND.Play does not work in WIndows environment. What's the preferred way to play sound files in this environment?

Many thanks in advance for your help!
Joerg
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Playing Soundfiles

Post by Stewart Marshall »

Hi Joerg

The sound control is a visual control, so it must be parented to the page or form. Usage is the same on Windows as it is in the browser.

The only major difference is where the files must be located. Forms have access to whatever locations are known to the executing machine, but the browser is limited to the LANSA runtime folders on the application server i.e. ..\x_PPP\web\vl

With regards to a playlist, the control has an Ended event that fires when a sound completes. All you need after that is a list of filenames and the entry number of the item currently being played.

Regards

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Height(752) Width(1118)

Define_Com Class(#Prim_sond) Name(#Sound) DisplayPosition(1) Parent(#COM_OWNER) TabPosition(1) Autoplay(False) Height(135) Width(263)

Evtroutine Handling(#Com_owner.CreateInstance)
#Sound.FileName := Chord.Wav
Endroutine

Evtroutine Handling(#com_owner.DoubleClick)
#Sound.Play
Endroutine

Evtroutine Handling(#Sound.Ended)
#Sound.Play
Endroutine

End_Com
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Re: Playing Soundfiles

Post by Joerg Hamacher »

Hi Stewart,

thank you for the example and the explanations.
It works fine, great!
But I am a little bit confused because when using #SOUND1.Play in a #PRIM_FORM component the VL editor says: "Play is not supported on Win32 and will have no effect".
Compile target is set to "32 bit" but it works nevertheless...

Regarding the web version: if I create a virtual sound file folder in IIS (something like localhost/soundfiles/mymusic) - can I access that in a VL webpage?

Best regards,
Joerg
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Playing Soundfiles

Post by Stewart Marshall »

Hi Joerg

With regards to Forms, there is a warning that a render type of Win32 does not support the play method. It may be that this was the case at some point and that we never took the warning out. If you're developing for DirectX the warning goes away.

As per my previous reply, you're limited to folders within the LANSA runtime structure. All path processing is relative to that and will obey the normal browser path rules.

Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
Post Reply