add mpv player w/ ipc support

This commit is contained in:
eyjhb 2025-02-04 19:29:03 +01:00
parent a706a38252
commit 6ae627522c
Signed by: eyjhb
GPG key ID: 609F508E3239F920
5 changed files with 216 additions and 23 deletions

63
main.go
View file

@ -2,6 +2,7 @@ package main
import (
"fmt"
"time"
"git.fricloud.dk/eyjhb/minifluxmpv/cmd"
tea "github.com/charmbracelet/bubbletea"
@ -9,36 +10,19 @@ import (
)
func main() {
// ipcc := mpv.NewIPCClient("/tmp/mpvsocket") // Lowlevel client
// c := mpv.NewClient(ipcc) // Highlevel client, can also use RPCClient
// c.Loadfile("https://www.youtube.com/watch?v=9dncyekT9d4", mpv.LoadFileModeReplace)
// // c.SetPause(true)
// // c.Seek(600, mpv.SeekModeAbsolute)
// // c.SetFullscreen(true)
// c.SetPause(false)
// // fmt.Println(c.Idle())
// // time.Sleep(10 * time.Second)
// // fmt.Println(c.Idle())
// for {
// pos, _ := c.Position()
// dur, _ := c.Duration()
// fmt.Printf("%f/%f\n", pos, dur)
// time.Sleep(1 * time.Second)
// }
// return
fmt.Println(test())
return
// init miniflux
client := miniflux.New("https://miniflux.fricloud.dk/v1/", "tFkVpjmSvePfGX6SBtcE61HSziALNAIeZ0eq5mkQOso=")
client := miniflux.New("https://miniflux.fricloud.dk/v1/", "F_61V4HkhhJjCF_hI12oDAYhgMY2769KAvOkqPsubqc=")
// init miniflux player
m := cmd.MinifluxPlayer{
MinifluxClient: client,
DefaultCategory: "",
MpvPath: "mpv",
CurrentView: cmd.ViewListFeedEntries,
}
// run tea program
@ -47,3 +31,38 @@ func main() {
}
}
func test() error {
p := cmd.NewMPVPlayer()
fmt.Println(p.IsPlaying())
err := p.Play("https://www.youtube.com/watch?v=gCYcHz2k5x0")
if err != nil {
return err
}
time.Sleep(10 * time.Second)
fmt.Println(p.IsPlaying())
// err = p.Play("https://www.youtube.com/watch?v=3d3ceC_EuC0")
// if err != nil {
// return err
// }
// time.Sleep(10 * time.Second)
// fmt.Println(p.VideoDuration)
// fmt.Println(p.VideoPosition)
// time.Sleep(1 * time.Second)
err = p.Stop()
if err != nil {
return err
}
fmt.Println("Started playing")
time.Sleep(100 * time.Second)
return nil
}