This topic is locked

play a sound file

5/28/2019 6:44:04 PM
PHPRunner General questions
N
nasa author

Hi

I am trying to run acode to play a sound file

But it does not work. Please help me

add to List page: javascript onload event.
var Audio1 = new Audio('files/best.mp3');

var Audio2 = new Audio('files/bad.mp3');
if ($data["TrueFalse"]=='True')

{
Audio1.play();

}

else

{
Audio2.play();

}

admin 5/30/2019

There are two issues I can see here.

  1. You are mixing PHP and Javascript code. In Javascript event you can only use Javacript code.
  2. Even if you use a correct code it is not clear what you trying to do as there are multiple records on the List page. Are you trying to play sound multiple times?

N
nasa author 5/30/2019

thank you Admin

a Field name is(TrueFalse)
A field value( True ) appears if a condition is met
Only when a record is added and a value( True ) is recorded in a field

The audio file is played once

admin 5/31/2019

Sorry, it still doesn't make much sense. The list page is designed to display multiple records. This means your field may appear multiple times there and sound will play multiple times. I would understand if you were talking about the View page but on List page doesn't make much sense.

N
nasa author 5/31/2019



Sorry, it still doesn't make much sense. The list page is designed to display multiple records. This means your field may appear multiple times there and sound will play multiple times. I would understand if you were talking about the View page but on List page doesn't make much sense.

N
nasa author 5/31/2019





Thank you Admin

I placed the code on the View page

But still does not work

N
nasa author 5/31/2019



Thank you Admin

I placed the code on the View page

But still does not work


I have modified the code and placed it in <View page>javascript onload event

It works properly

But how to make it work on <List page> javascript onload event. only once when you add a new record
var ctrl = Runner.getControl(pageid, "TrueFalse");

var Audio1 = new Audio('files/best.mp3');

var Audio2 = new Audio('files/bad.mp3');
if(ctrl.getValue()=="True")

{

Audio1.play();
}

else

{

(ctrl.getValue()=="False")
Audio2.play();

}