piplayer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: MIT Imports: 20 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 LoginHandler

func LoginHandler(conf *Config) 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

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) 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-browser process that is used to display web pages and still images to the screen

type Config

type Config struct {
	Location    string
	Directory   string
	AudioOutput string
	Debug       bool
	Login       Login
	Remote      remote
}

Config holds the configuration of the pi-player

func (*Config) HandleSettings

func (conf *Config) HandleSettings(w http.ResponseWriter, r *http.Request)

HandleSettings handles requests to the settings page

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

type ConnectionWS

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

ConnectionWS represents a WebSocket connection.

func (*ConnectionWS) HandlerWebsocket

func (c *ConnectionWS) HandlerWebsocket(p *Player) http.HandlerFunc

HandlerWebsocket handles websocket connections for the browser viewer and controller.

type Item

type Item struct {
	Audio  os.FileInfo
	Visual os.FileInfo
	Type   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
}

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 Player

type Player struct {
	ConnViewer  ConnectionWS
	ConnControl ConnectionWS
	// contains filtered or unexported fields
}

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

func NewPlayer

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

NewPlayer creates a new Player

func (*Player) CleanUp

func (p *Player) CleanUp()

CleanUp closes other components properly

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

func (*Player) HandleWebSocketMessage

func (p *Player) HandleWebSocketMessage()

HandleWebSocketMessage handles messages from ConnectionWS that come from the browser's websocket connection

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 Playlist

type Playlist struct {
	Name    string
	Items   []Item
	Current *Item
}

Playlist stores the media items that can be played

func NewPlaylist

func NewPlaylist(dir string) (Playlist, error)

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

type TemplateHandler

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

TemplateHandler handles rendering html templates

func NewTemplateHandler

func NewTemplateHandler(filename string) 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