piplayer

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLogin

func CheckLogin(w http.ResponseWriter, r *http.Request) (*sessions.Session, bool, error)

CheckLogin checks if the user is logged in

func Listen added in v0.1.5

func Listen(ctx context.Context, devs []string, p *Player) []error

Listen to all the Input Devices supplied. Return an error if there is a problem, or if one of the devices disconnects.

func LoginHandler

func LoginHandler(p *Player) http.HandlerFunc

LoginHandler handles login requests

func LogoutHandler

func LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler logs a user out and redirects them to the login page

func NewServer added in v0.1.1

func NewServer(p *Player, addr string) *http.Server

NewServer returns a new http.Server for the piplayer interface.

func Start added in v0.1.1

func Start(plr *Player)

Start the http server.

Types

type APIHandler

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

APIHandler handles requests to the API

func NewAPIHandler

func NewAPIHandler(debug bool, test *string, statAssets, statTemplates embed.FS) APIHandler

NewAPIHandler creates a new APIHandler

func (*APIHandler) Handle

func (a *APIHandler) Handle(p *Player) http.HandlerFunc

Handle handles all calls to the API

type Browser

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

Browser represents the chromium process that is used to display web pages and still images to the screen

type Chrome added in v0.1.1

type Chrome struct {
	Supports []string

	ConnViewer  ConnectionWS
	ConnControl ConnectionWS
	// contains filtered or unexported fields
}

Chrome represents Google Chrome as the video stream playback software. It implements the streamer interface.

func (*Chrome) AudioStream added in v0.1.1

func (c *Chrome) AudioStream(a int) error

AudioStream sets the video audio stream.

func (*Chrome) Chapter added in v0.1.1

func (c *Chrome) Chapter(chp int) error

Chapter seeks to a specific chapter in the video.

func (*Chrome) Close added in v0.1.1

func (c *Chrome) Close() error

Close closes Google Chrome.

func (*Chrome) Listen added in v0.1.1

func (c *Chrome) Listen(s chan string) error

Listen does nothing for now.

func (*Chrome) Open added in v0.1.1

func (c *Chrome) Open(file string, status chan string, test string, debug bool) error

Open starts Chrome in the relevant page with the relevant flags.

func (*Chrome) Pause added in v0.1.1

func (c *Chrome) Pause() error

Pause sends a pause command.

func (*Chrome) Play added in v0.1.1

func (c *Chrome) Play() error

Play sends a play command.

func (*Chrome) PlaybackRate added in v0.1.1

func (c *Chrome) PlaybackRate(rate int) error

PlaybackRate sets the video playback rate.

func (*Chrome) Seek added in v0.1.1

func (c *Chrome) Seek(seconds int) error

Seek seeks to a specific time in a video.

func (*Chrome) SubtitleStream added in v0.1.1

func (c *Chrome) SubtitleStream(s int) error

SubtitleStream sets the video subtitle stream.

func (*Chrome) Volume added in v0.1.1

func (c *Chrome) Volume(v int) error

Volume sets the video volume.

type Config

type Config struct {
	Location    string
	Mount       mount
	AudioOutput string
	Streamer    string
	Debug       bool
	Login       Login
	Remote      remote
}

Config holds the configuration of the pi-player

func (*Config) Load

func (conf *Config) Load(path string) error

Load reads the config file and unmarshalls it to the config struct

func (*Config) Save

func (conf *Config) Save(path string) error

Save reads the config struct, marshalls it and writes it to the config file

func (*Config) SettingsHandler added in v0.1.1

func (conf *Config) SettingsHandler(p *Player) http.HandlerFunc

SettingsHandler handles requests to the settings page

type ConnectionWS

type ConnectionWS interface {
	HandlerWebsocket(p *Player) http.HandlerFunc
	// contains filtered or unexported methods
}

ConnectionWS represents a WebSocket connection.

func NewConnWS added in v0.1.2

func NewConnWS() ConnectionWS

NewConnWS returns a new websocket connection struct.

type Item

type Item struct {
	Audio  fs.DirEntry
	Visual fs.DirEntry
	Type   string
	Cues   map[string]string
}

Item represents a playlist item it can have a visual element, an audio element, or both. more elements such as timers can be added later.

func (*Item) Name

func (i *Item) Name() string

Name returns the filename of the visual element.

func (*Item) String

func (i *Item) String() ItemString

String returns an newly created ItemString version of the Item.

type ItemString

type ItemString struct {
	Audio  string
	Visual string
	Type   string
	Cues   map[string]string
}

ItemString is a simpler representation of an Item, where only the file name for the Audio and Visual elements are stored.

type Login

type Login struct {
	Username string
	Password string
}

Login holds the credentials to the single user in the system.

type OMXPlayer added in v0.1.1

type OMXPlayer struct {
	Supports []string
	// contains filtered or unexported fields
}

OMXPlayer uses OMXPlayer to stream H.264 files to the screen. It implements the Streamer interface.

func (*OMXPlayer) AudioStream added in v0.1.1

func (o *OMXPlayer) AudioStream(index int) error

AudioStream sets the specified video audio stream.

func (*OMXPlayer) Chapter added in v0.1.1

func (o *OMXPlayer) Chapter(index int) error

Chapter brings the video to the specified chatper.

func (*OMXPlayer) Close added in v0.1.1

func (o *OMXPlayer) Close() error

Close stops the video and closes the streamer process.

func (*OMXPlayer) Open added in v0.1.1

func (o *OMXPlayer) Open(filename string, status chan string, test string, debug bool) error

Open starts a video file in the OMXPlayer streamer.

func (*OMXPlayer) Pause added in v0.1.1

func (o *OMXPlayer) Pause() error

Pause pauses the video playback.

func (*OMXPlayer) Play added in v0.1.1

func (o *OMXPlayer) Play() error

Play resumes video playback.

func (*OMXPlayer) PlaybackRate added in v0.1.1

func (o *OMXPlayer) PlaybackRate(speed int) error

PlaybackRate sets the video playback speed.

func (*OMXPlayer) Seek added in v0.1.1

func (o *OMXPlayer) Seek(direction int) error

Seek seeks the video to a certain time.

func (*OMXPlayer) SubtitleStream added in v0.1.1

func (o *OMXPlayer) SubtitleStream(index int) error

SubtitleStream sets the subtitle stream.

func (*OMXPlayer) Volume added in v0.1.1

func (o *OMXPlayer) Volume(vol int) error

Volume sets the video volume.

type Player

type Player struct {
	ConnViewer  ConnectionWS
	ConnControl ConnectionWS
	Server      *http.Server
	// contains filtered or unexported fields
}

Player is the object that renders images to the screen through omxplayer or chromium

func NewPlayer

func NewPlayer(api *APIHandler, conf *Config, keylogger *keylogger.KeyLogger) *Player

NewPlayer creates a new Player server *http.Server, router *mux.Router

func (*Player) FirstRun

func (p *Player) FirstRun()

FirstRun starts the browser on a black screen and gets things going

func (*Player) HandleControl

func (p *Player) HandleControl(w http.ResponseWriter, r *http.Request)

HandleControl Scan the folder for new files every time the page reloads and display contents

func (*Player) HandleViewer

func (p *Player) HandleViewer(w http.ResponseWriter, r *http.Request)

HandleViewer handles requests to the image viewer page This handler has a dependency on Playlist.

func (*Player) Listen added in v0.1.1

func (p *Player) Listen(s chan string)

Listen should listen to something, I forgot what

func (*Player) Next added in v0.1.1

func (p *Player) Next() error

Next goes to the next item in the playlist.

func (*Player) Previous added in v0.1.1

func (p *Player) Previous() error

Previous goes to the previous item in the playlist.

func (*Player) ServeHTTP

func (p *Player) ServeHTTP(w http.ResponseWriter, h *http.Request)

Handles requets to the player api

func (*Player) Start

func (p *Player) Start(w *http.ResponseWriter)

Start the file that will be played in the browser. Sends a message to the ConnViewer channel to be sent over the websocket.

type Player2 added in v0.1.1

type Player2 interface {
	Start(i Item)
	Stop() error
	Next() error
	Previous() error
	Listen(s chan string)
}

Player2 represents the entire program. It's the shell that holds the components together. The other components are the Streamer, Playlist, and Remote

type Playlist

type Playlist struct {
	Name    string
	Items   []Item
	Current *Item
	// contains filtered or unexported fields
}

Playlist stores the media items that can be played.

func NewPlaylist

func NewPlaylist(p *Player, dir string) (*Playlist, error)

NewPlaylist creates a new playlist with media in the designated folder.

type Presentation added in v0.1.1

type Presentation struct {
	Items []ItemString
}

Presentation is used to read the presentation.json file for added cues.

type Streamer added in v0.1.1

type Streamer interface {
	Open(file string, status chan string, test string, debug bool) error
	Close() error
	Play() error
	Pause() error
	PlaybackRate(rate int) error
	Seek(seconds int) error
	Chapter(chapter int) error
	Volume(volume int) error
	AudioStream(stream int) error
	SubtitleStream(stream int) error
}

Streamer represents a program that can decode a media file for display. It is the code that actually plays a media file. Eg: OMXPlayer, VLC and Chrome.

func NewStreamer added in v0.1.1

func NewStreamer(name string, audioOutput string) (s Streamer, err error)

NewStreamer creates a new streamer object based on the type supplied.

type TemplateHandler

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

TemplateHandler handles rendering html templates

func NewTemplateHandler

func NewTemplateHandler(filename string, statTemplates fs.FS) TemplateHandler

NewTemplateHandler returns a new template handler for a specific page

func (*TemplateHandler) ServeHTTP

func (t *TemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests for the templates

Jump to

Keyboard shortcuts

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