audio API structure

Following listing presents audio API is built.

//robot.audio.player and robot.audio.recorder are copies (full or partial) of UPlayeNext module:
var Global.PlayerNext1=UPlayerNext.new();//new player next instance
Global.PlayerNext1.addProto(Interface);//object GlobalPlayNext1 inherits Interface prototype
//the above step in required before adding object to robot structure as a device
robot.audio.addDevice("player", Global.PlayerNext1);//instance of UPlayerNext is added to robot.audio as player (whole module is copied to structure)
//in case of robot.audio.recorder we copy only one slot and prepare our own interface to functions
var Global.PlayerNext2=UPlayerNext.new();
robot.audio.addComponent("recorder");//we create new element of structure - now we can use robot.audio.recorder (but it is empty)
PlayerNext2.getSlot("inputDevices").copy(robot.audio.recorder,"inputDevices");//we copy only one slot from PlayerNext2 object to robot.audio.recorder
//we want to have different function names than in module, so we define new functions in robot.audio.recorder structure, which are simply calling the ones from PlayerNext2 object
do(robot.audio.recorder)
{
function SetRecordLevel(input,level) { call.PlayerNext2.SetRecordLevel(input,level); };
function Start(input_device,filename) { call.PlayerNext2.StartRecord(input_device,filename); };
function Stop() { call.PlayerNext2.StopRecord(); };
};

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation