Creating your Own Player

 

You can create your own player application using the SDK. This application won’t need to run in VirtualUI web mode, since it will only use the VirtualUI.Recorder component for playing sessions.

 

This component will read a previously saved recording to reproduce the same commands that originally were sent by VirtualUI Server to the web browser when running the application. So, an instance of both VirtualUI Player Server and VirtualUI Server —in developer mode— will be automatically launched. You will need also the Development Server URL —by default http://127.0.0.1:6080— to open in the browser.

 

 

You will also need:

- A VirtualUI Player Server instance.

- A VirtualUI Server in development mode instance.

- A browser instance where the development Server URL (tipically http://127.0.0.1:6080) is open.

 

The first two are automatically executed when using the Recorder player options.

 

The playing properties are:

 

State

It reports the Recorder state. It's Inactive (0) when no action is being made, Recording (1) when a session is being recorded, and Playing (2) when a session is being played.

Count

Total count of entries in the session file. Each entry is an internal VirtualUI command. The initial position of each track points to one of these file entries.

Position

Current entry being played.

Tracks

List of tracks in the session file. Each track, which is an IRecTrack interface, has two properties:

 

Name

Original name specified in the Rec() method.

Position

Entry number in the session file, where the track starts. This value is always between 0 and Count.

 

First, set the FileName property in the player application to the IDX file name of the session that will be played:

 

Delphi code:

VirtualUI.Recorder.Filename := 'C:\Sessions\VirtualUISession.idx';

 

This will complete the Recorder properties and enable the session to be played, as long as the development URL is open in the browser.

 

Use the Play method to start playing a session. This method receives two parameters that indicate the initial and final entries to be played.

 

To reproduce a complete session,  you can either send 0 as the beginning and Count as the ending:

 

Delphi code:

VirtualUI.Recorder.Play(0, VirtualUI.Recorder.Count-1);

 

or send -1 in  both parameters:

 

Delphi code:

VirtualUI.Recorder.Play(-1, -1);

 

If you wish to play a particular track, send the track range in the Play parameters. The Position property of every track is also the entry number of the beginning, as well the entry number of the ending for the previous track in the list. For the last track, the ending is the Count property.

 

To stop playing a session before it finishes, use the Stop method:

 

Delphi code:

VirtualUI.Recorder.Stop();

 

 

Read more:

Recording a Session
The OnRecorderChanged Event
Playing Recorded Sessions