Play a sound file from Rich Display File App
-
- New User
- Posts: 7
- Joined: Tue Sep 01, 2015 10:24 am
- First Name: Robert
- Last Name: Bucklad
- Company Name: Astro-Med
- Phone: 401 828-4000 x231
- Address 1: 600 East Greenwich Ave
- City: West Warwick
- State / Province: Rhode Island
- Zip / Postal Code: 02893
- Country: United States
- Contact:
Play a sound file from Rich Display File App
I bet Scott Clement can answer this...
How do we play a sound (.wav) or something when an event occurs?
Example (amount > limit) "BUZZZZZZZZ"
The last topic for .wav was back in 2011 (Brian May). We hope newer versions may have been enhanced.
Thanks
How do we play a sound (.wav) or something when an event occurs?
Example (amount > limit) "BUZZZZZZZZ"
The last topic for .wav was back in 2011 (Brian May). We hope newer versions may have been enhanced.
Thanks
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Play a sound file from Rich Display File App
https://www.w3schools.com/jsref/met_audio_play.asp
Is there something more specialized about this that you need to know, or...?
Is there something more specialized about this that you need to know, or...?
-
- New User
- Posts: 7
- Joined: Tue Sep 01, 2015 10:24 am
- First Name: Robert
- Last Name: Bucklad
- Company Name: Astro-Med
- Phone: 401 828-4000 x231
- Address 1: 600 East Greenwich Ave
- City: West Warwick
- State / Province: Rhode Island
- Zip / Postal Code: 02893
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
Sorry about mis-spelling your name... I must be distracted...
Can we play a .wav file in windows from an RPGLE program? If so, any examples available?
Thank you very much Scott Klement !
Can we play a .wav file in windows from an RPGLE program? If so, any examples available?
Thank you very much Scott Klement !
-
- New User
- Posts: 7
- Joined: Tue Sep 01, 2015 10:24 am
- First Name: Robert
- Last Name: Bucklad
- Company Name: Astro-Med
- Phone: 401 828-4000 x231
- Address 1: 600 East Greenwich Ave
- City: West Warwick
- State / Province: Rhode Island
- Zip / Postal Code: 02893
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
Scott, I just realized that we already use the js functions() in the default IFS dir "custom"
So I guess we would put another function from the link you sent - triggered by an event ("On Change") or something.
I do have a .js file named for a specific application program that retains column filters, can I just add another .js file and will ProfoundUI search ALL the .js files in custom for a function? Should I not name the .js file for the application and call it something else since I do not refer to the .js file on the event call "myonsubmit()" ... Thanks
So I guess we would put another function from the link you sent - triggered by an event ("On Change") or something.
I do have a .js file named for a specific application program that retains column filters, can I just add another .js file and will ProfoundUI search ALL the .js files in custom for a function? Should I not name the .js file for the application and call it something else since I do not refer to the .js file on the event call "myonsubmit()" ... Thanks
- Glenn
- Profound Logic Staff Member
- Posts: 124
- Joined: Mon Apr 14, 2014 4:08 pm
- First Name: Glenn
- Last Name: Hopwood
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
If you are running a Rich Display session (using the /start URL) then, yes, Profound UI will load anything you put in /custom. If you are running a Genie session you will need to add an additional <script> tag to the start.html file of your skin if you create a new .js file in custom.
How you name the .js files in the /custom directory depends on how you want to group things. Some customers might create one file with everything in it or break them into different files based on some shop standard.
Glenn
How you name the .js files in the /custom directory depends on how you want to group things. Some customers might create one file with everything in it or break them into different files based on some shop standard.
Glenn
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Play a sound file from Rich Display File App
I'm not sure that I understand how the .js files in userdata/custom are related. Are you saying that you'll put the JS code to play a wav file into a function, and then call it when you need it?
You can do that -- but it is only one or two lines of code, so it seems like it's not necessary to do that?
For example, you could simply put this in any JavaScript event (onload, onchange, onclick, etc):
Replace "/tada.wav" with the URL to any wave file you want to play.
Or, if you wanted it to be a one-liner, you could do this (I think it's a bit harder to read, but it's up to you):
If you only want to do it based on a condition in your RPG program, of course, you could set a hidden field in your display file, and check that field from JavaScript. So maybe you'd create a hidden textbox with id=PLAYDATA, bound to RPG variable PLAYTADA. The RPG variable could put 'Y' into the field, then do EXFMT to show your screen. The onload of the screen could do this:
I hope you're getting the idea! Really, none of this is related to Profound UI -- it is just 'regular' web programming that will work in any web page, whether it's Profound UI or not... You can Google it and find hundreds, even thousands, of pages telling you how to do it. I linked one of them in my previous message.
To me, this is a very simple example of why it's powerful that Profound UI is based on mainstream technologies like HTML5. There doesn't need to be any features in Profound UI for this because you can take advantage of all of the built-in capabilities of the web browser.
You can do that -- but it is only one or two lines of code, so it seems like it's not necessary to do that?
For example, you could simply put this in any JavaScript event (onload, onchange, onclick, etc):
Code: Select all
var sound = new Audio('/tada.wav');
sound.play();
Or, if you wanted it to be a one-liner, you could do this (I think it's a bit harder to read, but it's up to you):
Code: Select all
new Audio('/tada.wav').play();
Code: Select all
if (get("PLAYTADA") == "Y") {
new Audio("/tada.wav").play();
}
To me, this is a very simple example of why it's powerful that Profound UI is based on mainstream technologies like HTML5. There doesn't need to be any features in Profound UI for this because you can take advantage of all of the built-in capabilities of the web browser.
-
- New User
- Posts: 7
- Joined: Tue Sep 01, 2015 10:24 am
- First Name: Robert
- Last Name: Bucklad
- Company Name: Astro-Med
- Phone: 401 828-4000 x231
- Address 1: 600 East Greenwich Ave
- City: West Warwick
- State / Province: Rhode Island
- Zip / Postal Code: 02893
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
Thank you very much Scott, once again. The information is very helpful to us. We are close to retirement so you know the saying about old dogs...
(we cheat).
:)
(we cheat).
:)
-
- New User
- Posts: 11
- Joined: Tue Sep 01, 2015 11:24 am
- First Name: Sayed
- Last Name: Mohsen
- Company Name: Astro-Med, Inc.
- Phone: 401-298-8605
- State / Province: Rhode Island
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
I tried the following code in onclick event of a button named 'Play1'.
var sound = new Audio('\\172.16.1.1\TEST\TADA.WAV');
sound.play();
"\\172.16.1.1\TEST\TADA.WAV" is my URL of the wave file. When I click the button 'Play1' nothing happens.
I must not be doing it right.
var sound = new Audio('\\172.16.1.1\TEST\TADA.WAV');
sound.play();
"\\172.16.1.1\TEST\TADA.WAV" is my URL of the wave file. When I click the button 'Play1' nothing happens.
I must not be doing it right.
- Glenn
- Profound Logic Staff Member
- Posts: 124
- Joined: Mon Apr 14, 2014 4:08 pm
- First Name: Glenn
- Last Name: Hopwood
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: Play a sound file from Rich Display File App
The web server will only allow the browser to access files in the document root (usually /www/<instance name>/htdocs). You will need to put the TADA.WAV file somewhere in that directory. You will then want to use only the path relative to the document root in the Audio() object.
For example, if you create a directory named 'test' in /www/<instance name>/htdocs you would make the first line to look like this...
var sound = new Audio('/test/tada.wav');
Glenn
For example, if you create a directory named 'test' in /www/<instance name>/htdocs you would make the first line to look like this...
var sound = new Audio('/test/tada.wav');
Glenn
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Play a sound file from Rich Display File App
What you've coded looks like a Windows UNC path. You need to provide a valid HTTP URL (relative or absolute).
So something like http://www.example.com/xxx/yyy.wav or just /xxx/yyy.wav (where it will use the same server as your display.)
Assuming you are serving the file from your IBM i, then it would indeed be within your document root as Glenn points out (unless you configure your HTTP server differently).
So something like http://www.example.com/xxx/yyy.wav or just /xxx/yyy.wav (where it will use the same server as your display.)
Assuming you are serving the file from your IBM i, then it would indeed be within your document root as Glenn points out (unless you configure your HTTP server differently).
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests