playlist

package
v0.0.0-...-a380f54 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: BSD-2-Clause Imports: 4 Imported by: 4

Documentation

Overview

Package playlist defines functionality for creating, manipulating and persisting playlists.

Index

Constants

View Source
const (
	ActionCreate Action = "create"
	ActionDelete        = "delete"

	ActionAddItem    = "addItem"
	ActionRemoveItem = "deleteItem"
)

Variables

This section is empty.

Functions

func Paths

func Paths(item *Item, c index.Collection) ([]index.Path, error)

Paths returns the list of paths for the tracks within the Item, using Collection as the data source.

Types

type Action

type Action string

Action is a type used to represent a playlist mutation action.

type Item

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

Item is a type which defines a playlist item.

func (*Item) AddTransform

func (i *Item) AddTransform(t Transformer)

AddTransform adds the Transformer to the Item.

func (*Item) MarshalJSON

func (i *Item) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Item) UnmarshalJSON

func (i *Item) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Playlist

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

Playlist is a basic implementation of a playlist

func (*Playlist) Add

func (p *Playlist) Add(path index.Path)

Add adds a new with the path to the Playlist.

func (*Playlist) Items

func (p *Playlist) Items() []*Item

Items returns a slice of *Item instances which represent each item in the playlist.

func (*Playlist) MarshalJSON

func (p *Playlist) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Playlist) Remove

func (p *Playlist) Remove(n int, path index.Path) error

Remove removes the item with index `n` and path `path` from the Playlist.

func (*Playlist) UnmarshalJSON

func (p *Playlist) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RemovePath

type RemovePath index.Path

RemovePath is a type which defines a RemovePath action for a specific index.Path, which removes a path from a playlist item.

func (RemovePath) MarshalJSON

func (r RemovePath) MarshalJSON() ([]byte, error)

Implements json.Marshaler.

func (RemovePath) Transform

func (RemovePath) Transform() string

Transform implements Transformer

type RepAction

type RepAction struct {
	Name   string     `json:"name"`
	Action Action     `json:"action"`
	Path   index.Path `json:"path"`
	Index  int        `json:"index"`
}

func (RepAction) Apply

func (a RepAction) Apply(s Store) error

type Store

type Store interface {
	// Names returns the name of playlists in the store.
	Names() []string

	// Get returns the playlist for the given name.
	Get(name string) *Playlist

	// Set sets the playlist for the given name.
	Set(name string, p *Playlist) error

	// Delete removes the playlist with the given name.
	Delete(name string) error
}

Store is an interface which defines methods for implementing a playlist store.

func NewStore

func NewStore(path string) (Store, error)

NewStore creates a basic implementation of a playlist store, using the given path as the source of data. If the file does not exist it will be created.

type Transformer

type Transformer interface {
	// Transform returns the action associated with the transformation.
	Transform() string
}

Transformer is an interface which defines the Transform method for making changes to playlist items.

Jump to

Keyboard shortcuts

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