Every time an event happens in HDFVR (a buttons is pressed, connection succeeds, etc.) a call is made to a JavaScript function with lots of info about the event!
You can extend these JS functions to:
Here is the list of events and associated JavaScript functions:
| Event | JavaScript function that is called | Parameters passed to the JS function |
|---|---|---|
| HDFVR is ready to communicate with JavaScript and Javascipt can call functions on HDFVR | onFlashReady(); | no params are sent to this function |
| HDFVR detects the number of cams and mics a user has | userHasCamMic(cam_number, mic_number); |
cam_number:number of web cam drivers the user has installed on his computer mic_number: number of sound card and sound sources the user has installed on his computer |
| [Record] button is pressed |
btRecordPressed(); | no params are sent to this function |
| [Stop Record] button is pressed | btStopRecordingPressed(); | no params are sent to this function |
| [Play] button is pressed |
btPlayPressed(); | no params are sent to this function |
| [Pause] busson is pressed | btPausePressed(); | no params are sent to this function |
| Recorded data finishes streaming/uploading to the media server | onUploadDone(streamName, streamDuration , userId); |
streamName: a string representing the name of the stream recorded on the video server including the .flv extension streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322) userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence |
[Save]
Note: The actual existence of the .flv file and .jpg snapshot do not depend on the [SAVE] button being pressed. This button will not be available during or before the recording process OR if hideSaveButton=1 in avc_settings.xxx. |
onSaveOk(streamName, streamDuration, userId, cameraName, micName); |
streamName: a string representing the name of the stream recorded on the video server including the .flv extension streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322) userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence cameraName:the name of the web cam driver the user has selected for capturing video data micName: the name of the sound card/mic driver the user has selected for capturing audio data |
| [Save] button is pressed and save_video_to_db.php executes and returns save=failed |
onSaveFailed(streamName, streamDuration, userId) |
streamName, streamDuration and userId take the same values as explained above |
| the user pressed the [save] button inside the recorder and the save_video_to_db.XXX script returned save=ok | onSaveJpgOk(streamName, userId) |
streamName and userId take the same values as explained above |
| the user pressed the [save] button inside the recorder but the save_video_to_db.XXX script returned save=fail | onSaveJpgFailed(streamName, userId) |
streamName and userId take the same values as explained above |
| (New in build 423) HDFVR initializes and requests access to the webcam and microhphone | onCamAccess(allowed) | allowed is true if: 1) the user clicked the Allow button OR 2) cliked Allow+Remember in a previous session (in which case the Privacy dialog box is not shown) and false if the user clicked the Deny button. If a user clicked Deny+Remeber in a previous session the Privacy dialog box will be shown. |
| (New in build 440) HDFVR finishes playback of recorded video stream | onPlaybackComplete() |
You can find these JavaScript functions defined and explained in more detail in the HTML files that come with the video recorder.
You can control the HDFVR application by making calls from JavaScript. This API has been added in build 347.
You can use the JS functions (mentioned below) after the onFlashReady() is called by the HDFVR application by using the following JavaScript syntax:
| Function Name | Event triggered | Parameters passed to the HDFVR function | Return Values |
|---|---|---|---|
| record(); | This call will trigger HDFVR to record a video stream or to rerecord one if one is already recorded (equivalent to pressing the RECORD button). | no params are sent to this function | this function does not return a value |
| stop(); | This call will trigger HDFVR to stop the recording of a stream if a recording is in progress or stop the playing of the stream if a stream is being played (equivalent to pressing the RECORD button). | no params are sent to this function | this function does not return a value |
| play(); | This call will play the recorded stream if there is one. This will not be available during or before the recording process (equivalent to pressing the PLAY button). | no params are sent to this function | this function does not return a value |
| pause(); | This call will pause the stream that is currently playing. This will not be available if there is no stream playing(equivalent to pressing the PAUSE button). | no params are sent to this function | this function does not return a value |
save(); Note: The actual existence of the .flv file and .jpg snapshot do not depend on this call being made. When the call is made (or when the [SAVE] button is pressed), HDFVR executes save_video_to_db.xxx on the web server and 2 JS READ API functions (onSaveOk and onSaveFailed) are then executed depending on the response. This call will not be available during or before the recording process OR if hideSaveButton=1 in avc_settings.xxx. |
This call is equivalent to pressing the [SAVE] button.
|
no params are sent to this function | this function does not return a value |
| openSettings(); | This call will open up the settings screen on HDFVR from which the user can choose its camera and microphone (equivalent to pressing the SETTINGS button).This is available at any time. | no params are sent to this function | this function does not return a value |
| getStreamName(); | This call will return the stream name at any time but beware that the name of the stream might not be set at the time of the call. This is useful when you need the name of the stream during the recording and you do not specify a certain name through the avc_settings.xxx file. | no params are sent to this function | a string ,the stream name. If the stream name is not set it will return an empty string |
| getStreamTime(); | This will return the time of the played or the currently recording stream. | no params are sent to this function | a string with the current length of the recording (if called during the recording process) or (if called during playback) the current position in the video |
Every time an important event happens in HDFVR (the [SAVE] button is pressed) a php/asp file is executed on the web server. Info about the event is sent (via GET variables) to the php/asp file when it is executed .
You can extend these files to:
Here is the list of events and associated php/asp files that are executed when the event happens:
| Event | file/script that is executed on the web server | variables sent to the script via GET |
|---|---|---|
| HDFVR initializes in the browser | avc_settings.php or avc_settings.asp | No variables are sent when this file is executed. This script returns variable/value pairs in plain text. These vars are used by HDFVR for colors, limits, media server info, etc... . Edit the avc_settings.xxx file with a text editor to change the value of the variables. |
| [Save] button is pressed |
save_video_to_db.php or avc_settings.asp | streamName: a string representing the name of the stream recorded on the video server including the .flv extension streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322) userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence |
By default HDFVR attempts to use the php files (avc_settings.php, save_video_to_db.php). To switch to asp you need to:
If you manage to port the functionality in the provided asp/php files to other server side scripting languages you can use the sscode flash var to force the video recorder to use the new server side files. For example if sscode=aspx HDFVR will try to execute avc_settings.aspx and so on... .
You might also be interested in how the video recorder works and the Documentation.