I’m trying to make a simple program to run a psychology study. The following code plays a sequence of tones at different intervals when compiled to neko. When trying to run the same code in HTML5 there is no audio. I’ve tried running this in chrome, firefox and ie with no luck. Is there some HTML5 specific audio initialization I’m missing?
package;
import haxe.Timer;
import openfl.Assets;
import openfl.display.Bitmap;
import openfl.display.Sprite;
import openfl.events.KeyboardEvent;
import openfl.events.TimerEvent;
import openfl.Lib;
import openfl.Lib.getTimer;
import openfl.media.Sound;
/**
* ...
* @author Bobby
*/
class Main extends Sprite
{
//delare vars
public var beepInterval = 500;
public var betweenTrialBreak = 1500;
public var startTime = 0.0;
public var stim = new Bitmap(Assets.getBitmapData("img/1.png"));
public var beep:Sound = Assets.getSound("audio/beep.wav");
public var stimList = new Array();
//Initialization
public function new()
{
super();
//populate stim list
stimList[1] = new Bitmap(Assets.getBitmapData("img/1.png"));
stimList[2] = new Bitmap(Assets.getBitmapData("img/2.png"));
stimList[3] = new Bitmap(Assets.getBitmapData("img/3.png"));
stimList[4] = new Bitmap(Assets.getBitmapData("img/4.png"));
startTime = Timer.stamp();
Timer.delay(playBeep, 500);
Timer.delay(playBeep, beepInterval * 2);
Timer.delay(playBeep, beepInterval * 3);
Timer.delay(playBeep, beepInterval * 4);
Timer.delay(presentStim, 1000);
}
public function playBeep() { //Plays a beep!
beep.play();
}
private function presentStim() { //Presents a stimulus
addChild (stim);
}
}