# Class: JSVideo

## JSVideo

#### new JSVideo()

Creates a video player pointing to files specified by the url

Source:
  - player.js, line 14

### Methods

#### CreateVideoCanvas()

This function creates the html elements (display, scroll bar and buttons) for the video player

Source:
  - player.js, line 103

#### DisplayFrame(i)

This function displays the frame at position i, as well as the annotations corresponding to such frame. If such frame is not available, it pauses the player, loads a chunk of frames starting from i and replays.

##### Parameters:

Name | Type | Description
--- | --- | ---
`i` | int | the index of the frame to be displayed

Source:
  - player.js, line 202

#### GenerateFrames()

This function generates the html elements that contain the loaded frames

Source:
  - player.js, line 190

#### GoToFrame(frame)

This function sets the player to frame 'frame'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | int | the index of the frame of interest

Source:
  - player.js, line 275

#### GoToFrameButtonClicked()

This function is called when the user clicks the Go to frame button. It displays the frame indicated by the text field

Source:
  - player.js, line 184

#### loadChunk(frame, duration, first_time)

This function loads a set of frames to the player.

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | int | the first frame to load
`duration` | int | the duration of the chunk to be loaded
`first_time` | bool | boolean indicating whether the function is called for the first time

Source:
  - player.js, line 439

#### loadFile(frame, first_time, response)

This function checks that the loaded frames are correct, stores them in the video structure It prepares the polygon for scaling.

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | int | the position corresponding to the first frame in the set
`first_time` | bool | boolean indicating whether it was the first frame load of the video
`response` | json | json with the set of jpg frames being loaded

Source:
  - player.js, line 70

#### NextFrame()

Displays the next frame in a video file according to the video rate.

Source:
  - player.js, line 332

#### Play(buttonClicked)

This function sets the player to play. It can be called when a chunk of needed frames is loaded or when the user hits the play button.

##### Parameters:

Name | Type | Description
--- | --- | ---
`buttonClicked` | bool | boolean indicating whether the user clicked the play button or the video was played because the chunks got loaded

Source:
  - player.js, line 309

#### seekChunkToDownload(frame)

This function looks for future frames that haven't been loaded yet and loads them into the player.

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | int | the frame index from which to start seeking

Source:
  - player.js, line 430

#### StepBackward()

This function goes to the previous frame.

Source:
  - player.js, line 392

#### StepBeginning()

This function goes to the start of the video.

Source:
  - player.js, line 408

#### StepEnd()

This function goes to the end of the video.

Source:
  - player.js, line 419

#### StepForward()

This function forces to go to the next frame, regardless of frame rate.

Source:
  - player.js, line 376

#### UpdateLoadbar(pos)

This function updates the position of the load bar.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pos` | float | float from 0 to 1 indicating the position of the load bar

Source:
  - player.js, line 301

#### UpdateScrollbar(pos)

This function updates the position of the scroll bar.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pos` | float | float from 0 to 1 indicating the position of the scroll bar

Source:
  - player.js, line 292