From 318fd2fda65e6a0a329a5fad5be3f81d54ccacff Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 21 Jul 2022 00:44:31 +0200 Subject: initial WIP commit --- player.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 player.go (limited to 'player.go') diff --git a/player.go b/player.go new file mode 100644 index 0000000..73b5441 --- /dev/null +++ b/player.go @@ -0,0 +1,35 @@ +package main + +import ( + "log" +) + +type Backend interface { + Play(song Song) + Pause() + Search(keyword string) []Song +} + +type Player struct { + Backends map[string]Backend +} + +func NewPlayer() Player { + available_backends := map[string]Backend{} + + spotify, err := NewSpotify() + if err != nil { + // log.Fatalln("Error during initialization of the spotify backend:", err.Error()) + log.Println("Error during initialization of the spotify backend:", err.Error()) + } + available_backends["spotify"] = spotify + + return Player{available_backends} +} + +func (player *Player) Play(song Song) { + player.Backends[song.Source].Play(song) +} + +func (player *Player) Pause() { +} -- cgit v1.2.3