### Navigation

- index
- modules |
- next |
- previous |
- Gate One Documentation »
- Gate One Applications »
- Terminal »
- Terminal Developer Documentation »

# The Playback Plugin

## JavaScript

playback.js - The client-side portion of Gate One's Playback plugin.

`GateOne.Playback.``addControls`()

  Adds the session playback controls to Gate One's element (`GateOne.prefs.goDiv`).

  Note

  Will not add playback controls if they're already present.

`GateOne.Playback.``hideControls`()

  Hides the playback controls.

`GateOne.Playback.``init`()

  Adds the playback controls to Gate One and adds some GUI elements to the Tools & Info panel. Also attaches the following events/functions:

      // Add our callback that adds an extra newline to all terminals
      GateOne.Events.on("terminal:new_terminal", GateOne.Playback.newTerminalCallback);
      // This makes sure our playback frames get added to the terminal object whenever the screen is updated
      GateOne.Events.on("terminal:term_updated", GateOne.Playback.pushPlaybackFrame);
      // This makes sure our prefs get saved along with everything else
      GateOne.Events.on("go:save_prefs", GateOne.Playback.savePrefsCallback)
      // Hide the playback controls when in grid view
      GateOne.Events.on("go:grid_view:open", GateOne.Playback.hideControls);
      // Show the playback controls when no longer in grid view
      GateOne.Events.on("go:grid_view:close", GateOne.Playback.showControls);

`GateOne.Playback.``newTerminalCallback`(term, calledTwice)

  This gets added to the 'terminal:new_terminal' event to ensure that there's some extra space at the bottom of each terminal to make room for the playback controls.

  It also calls `GateOne.Playback.addControls()` to make sure they're present only after a new terminal is open.

`GateOne.Playback.``playPauseControl`(e)

  Toggles play/pause inside the current terminal. Meant to be attached to the Play/Pause icon's onclick event.

`GateOne.Playback.``playbackRealtime`(term)

  Plays back the given terminal's session one frame at a time. Meant to be used inside of an interval timer.

`GateOne.Playback.``pushPlaybackFrame`(term)

  Adds the current screen of term to `GateOne.Terminal.terminals[term].playbackFrames`.

`GateOne.Playback.``savePrefsCallback`()

  Called when the user clicks the "Save" button in the prefs panel. Makes sure the 'playbackFrames' setting gets updated according to what the user entered into the form.

`GateOne.Playback.``saveRecording`(term)

  Saves the session playback recording by sending the given term's 'playbackFrames' to the server to have them rendered.

  When the server is done rendering the recording it will be sent back to the client via the 'save_file' WebSocket action.

`GateOne.Playback.``selectFrame`(term, ms)

  For the given term, returns the last frame # with a 'time' less than the first frame's time + ms.

`GateOne.Playback.``showsControls`()

  Shows the playback controls again after they've been hidden via `GateOne.Playback.hideControls()`.

`GateOne.Playback.``startPlayback`(term)

  Plays back the given terminal's session in real-time.

`GateOne.Playback.``switchWorkspaceEvent`(workspace)

  Called whenever Gate One switches to a new workspace; checks whether or not this workspace is home to a terminal and if so, shows the playback controls.

  If no terminal is present in the current workspace the playback controls will be removed.

`GateOne.Playback.``updateClock`([dateObj])

  Updates the clock with the time in the given dateObj.

  If no dateObj is given, the clock will be updated with the current local time.

## Python

playback.py - A plugin for Gate One that adds support for saving and playing back session recordings.

Note

Yes this only contains one function and it is exposed to clients through a WebSocket hook.

### Hooks

This Python plugin file implements the following hooks:

    hooks = {
        'WebSocket': {
            'playback_save_recording': save_recording,
        }
    }

### Docstrings

`playback.``get_256_colors`(self)

  Returns the rendered 256-color CSS.

`playback.``save_recording`(self, settings)

  Handles uploads of session recordings and returns them to the client in a self-contained HTML file that will auto-start playback.

  ..note:: The real crux of the code that handles this is in the template.

### Navigation

- index
- modules |
- next |
- previous |
- Gate One Documentation »
- Gate One Applications »
- Terminal »
- Terminal Developer Documentation »