initial commit
This commit is contained in:
133
props_get.go
Normal file
133
props_get.go
Normal file
@ -0,0 +1,133 @@
|
||||
package mpvipc
|
||||
|
||||
import "time"
|
||||
|
||||
// list of (almost) all properties can be found in official docs:
|
||||
// https://mpv.io/manual/master/#properties
|
||||
|
||||
func IsFullscreen(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "fullscreen")
|
||||
}
|
||||
|
||||
func IsPaused(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "pause")
|
||||
}
|
||||
|
||||
func GetFilename(socket string) (string, error) {
|
||||
return GetProperty[string](socket, "filename")
|
||||
}
|
||||
|
||||
func GetEstimatedFrameCount(socket string) (int, error) {
|
||||
return GetProperty[int](socket, "estimated-frame-count")
|
||||
}
|
||||
|
||||
func GetEstimatedFrameNumber(socket string) (int, error) {
|
||||
return GetProperty[int](socket, "estimated-frame-number")
|
||||
}
|
||||
|
||||
func GetPID(socket string) (int, error) {
|
||||
return GetProperty[int](socket, "pid")
|
||||
}
|
||||
|
||||
func GetPath(socket string) (string, error) {
|
||||
return GetProperty[string](socket, "path")
|
||||
}
|
||||
|
||||
func GetMediaTitle(socket string) (string, error) {
|
||||
return GetProperty[string](socket, "media-title")
|
||||
}
|
||||
|
||||
func GetFileFormat(socket string) (string, error) {
|
||||
return GetProperty[string](socket, "file-format")
|
||||
}
|
||||
|
||||
func GetDuration(socket string) (time.Duration, error) {
|
||||
durationInSeconds, err := GetProperty[float64](socket, "duration")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return time.Duration(durationInSeconds * float64(time.Second)), nil
|
||||
}
|
||||
|
||||
func GetPercentPos(socket string) (float64, error) {
|
||||
return GetProperty[float64](socket, "percent-pos")
|
||||
}
|
||||
|
||||
func GetTimePos(socket string) (time.Duration, error) {
|
||||
durationInSeconds, err := GetProperty[float64](socket, "time-pos")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return time.Duration(durationInSeconds * float64(time.Second)), nil
|
||||
}
|
||||
|
||||
func GetTimeRemaining(socket string) (time.Duration, error) {
|
||||
durationInSeconds, err := GetProperty[float64](socket, "time-remaining")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return time.Duration(durationInSeconds * float64(time.Second)), nil
|
||||
}
|
||||
|
||||
func IsSeeking(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "seeking")
|
||||
}
|
||||
|
||||
func GetVideoFormat(socket string) (string, error) {
|
||||
return GetProperty[string](socket, "video-format")
|
||||
}
|
||||
|
||||
func GetVideoSize(socket string) (int, int, error) {
|
||||
width, err := GetProperty[int](socket, "width")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
height, err := GetProperty[int](socket, "height")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return width, height, nil
|
||||
}
|
||||
|
||||
func GetVideoDisplaySize(socket string) (int, int, error) {
|
||||
width, err := GetProperty[int](socket, "dwidth")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
height, err := GetProperty[int](socket, "dheight")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return width, height, nil
|
||||
}
|
||||
|
||||
func GetWindowID(socket string) (int64, error) {
|
||||
return GetProperty[int64](socket, "window-id")
|
||||
}
|
||||
|
||||
func GetChapterList(socket string) ([]Chapter, error) {
|
||||
return GetProperty[[]Chapter](socket, "chapter-list")
|
||||
}
|
||||
|
||||
func IsSeekable(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "seekable")
|
||||
}
|
||||
|
||||
func IsPartiallySeekable(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "partially-seekable")
|
||||
}
|
||||
|
||||
func IsPlaybackAborted(socket string) (bool, error) {
|
||||
return GetProperty[bool](socket, "playback-abort")
|
||||
}
|
||||
|
||||
func GetPropertyList(socket string) ([]string, error) {
|
||||
return GetProperty[[]string](socket, "property-list")
|
||||
}
|
Reference in New Issue
Block a user