player

package
v0.0.0-...-5c79d48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package player includes an API to play back recorded sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Clock     clockwork.Clock
	Log       logrus.FieldLogger
	SessionID session.ID
	Streamer  Streamer
}

Config configures a session player.

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player is used to stream recorded sessions over a channel.

func New

func New(cfg *Config) (*Player, error)

func (*Player) C

func (p *Player) C() <-chan events.AuditEvent

C returns a read only channel of recorded session events. The player manages the timing of events and writes them to the channel when they should be rendered. The channel is closed when the player has reached the end of playback.

func (*Player) Close

func (p *Player) Close() error

Close shuts down the player and cancels any streams that are in progress.

func (*Player) Err

func (p *Player) Err() error

Err returns the error (if any) that occurred during playback. It should only be called after the channel returned by [C] is closed.

func (*Player) LastPlayed

func (p *Player) LastPlayed() int64

LastPlayed returns the time of the last played event, expressed as milliseconds since the start of the session.

func (*Player) Pause

func (p *Player) Pause() error

Pause temporarily stops the player from emitting events. It is a no-op if playback is currently paused.

func (*Player) Play

func (p *Player) Play() error

Play starts emitting events. It is used to start playback for the first time and to resume playing after the player is paused.

func (*Player) SetPos

func (p *Player) SetPos(d time.Duration) error

SetPos sets playback to a specific time, expressed as a duration from the beginning of the session. A duration of 0 restarts playback from the beginning. A duration greater than the length of the session will cause playback to rapidly advance to the end of the recording.

func (*Player) SetSpeed

func (p *Player) SetSpeed(s float64) error

SetSpeed adjusts the playback speed of the player. It can be called at any time (the player can be in a playing or paused state). A speed of 1.0 plays back at regular speed, while a speed of 2.0 plays back twice as fast as originally recorded. Valid speeds range from 0.25 to 16.0.

type Streamer

type Streamer interface {
	StreamSessionEvents(
		ctx context.Context,
		sessionID session.ID,
		startIndex int64,
	) (chan events.AuditEvent, chan error)
}

Streamer is the underlying streamer that provides access to recorded session events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL