package mpvipc import ( "context" "time" "git.milar.in/milarin/channel" ) func ObserveDisplayNames(ctx context.Context, socket string) (<-chan []string, error) { return ObserveProperty[[]string](ctx, socket, "display-names") } func ObserveFullscreen(ctx context.Context, socket string) (<-chan bool, error) { return ObserveProperty[bool](ctx, socket, "fullscreen") } func ObservePaused(ctx context.Context, socket string) (<-chan bool, error) { return ObserveProperty[bool](ctx, socket, "pause") } func ObserveFilename(ctx context.Context, socket string) (<-chan string, error) { return ObserveProperty[string](ctx, socket, "filename") } func ObservePath(ctx context.Context, socket string) (<-chan string, error) { return ObserveProperty[string](ctx, socket, "path") } func ObserveMediaTitle(ctx context.Context, socket string) (<-chan string, error) { return ObserveProperty[string](ctx, socket, "media-title") } func ObserveFileFormat(ctx context.Context, socket string) (<-chan string, error) { return ObserveProperty[string](ctx, socket, "file-format") } func ObserveDuration(ctx context.Context, socket string) (<-chan time.Duration, error) { out, err := ObserveProperty[float64](ctx, socket, "duration") if err != nil { return nil, err } return channel.MapSuccessive(out, func(v float64) time.Duration { return time.Duration(v * float64(time.Second)) }), nil } func ObservePercentPos(ctx context.Context, socket string) (<-chan float64, error) { return ObserveProperty[float64](ctx, socket, "percent-pos") } func ObserveTimePos(ctx context.Context, socket string) (<-chan time.Duration, error) { out, err := ObserveProperty[float64](ctx, socket, "time-pos") if err != nil { return nil, err } return channel.MapSuccessive(out, func(v float64) time.Duration { return time.Duration(v * float64(time.Second)) }), nil } func ObserveTimeRemaining(ctx context.Context, socket string) (<-chan time.Duration, error) { out, err := ObserveProperty[float64](ctx, socket, "time-remaining") if err != nil { return nil, err } return channel.MapSuccessive(out, func(v float64) time.Duration { return time.Duration(v * float64(time.Second)) }), nil } func ObserveVideoFormat(ctx context.Context, socket string) (<-chan string, error) { return ObserveProperty[string](ctx, socket, "video-format") } func ObservePlaybackAborted(ctx context.Context, socket string) (<-chan bool, error) { return ObserveProperty[bool](ctx, socket, "playback-abort") }