Scripting

A Python script on the same computer can control Njord Player 3. It can:

  • read and move the playhead, to a time or by a number of seconds;
  • play and pause;
  • list the document's boats and choose which are shown;
  • list your workspaces and switch between them;
  • open a document;
  • follow the playhead as it moves.

That is enough to keep another tool in step with the debrief — a second analysis program following the player's playhead, for instance — or to drive a presentation from a script.

Getting started

Install the njord-player-remote package from PyPI. It needs Python 3.11 or later and has no other dependencies.

pip install njord-player-remote

While only a release candidate of the package is published, add --pre: pip install --pre njord-player-remote.

With Njord Player 3 running, this moves the playhead back 30 seconds and starts playback:

from njord_player_remote import Player

with Player.connect() as p:
    p.seek_by(-30)
    p.play()

The package's page on PyPI has examples for each of the things listed above.

What to know

  • There is nothing to switch on. The player accepts scripts whenever it is running, on macOS and Windows.
  • Only from your own account on that computer. A script has to run on the same computer, under the same user account as the player. Nothing on the network can connect.
  • A script acts as you would. Seeking, playing, choosing boats, switching workspace and opening a document take effect exactly as the same action in the app does. A script cannot open a document over one with unsaved changes.
  • Player 2 has no scripting interface.