Documentation
¶
Index ¶
- Variables
- func ClientAPIVersion() (major, minor uint32, err error)
- func LanguageName(code string) string
- func LibraryPath() (string, error)
- func Load() error
- func SetLibraryPath(path string)
- func View(c *ui.Context, p *Player) ui.Element
- type CacheRange
- type Chapter
- type HWDecMode
- type OpenOptions
- type Options
- type PlaybackStats
- type Player
- func (p *Player) AddSubtitleFile(path string, flags ...SubtitleFlag) error
- func (p *Player) AudioTracks() []Track
- func (p *Player) Chapters() []Chapter
- func (p *Player) Close() error
- func (p *Player) CurrentHWDec() string
- func (p *Player) DisableAudioTrack() error
- func (p *Player) DisableSecondarySubtitleTrack() error
- func (p *Player) DisableSubtitleTrack() error
- func (p *Player) FrameBackStep() error
- func (p *Player) FrameSize() (width, height int)
- func (p *Player) FrameStep() error
- func (p *Player) FramesRendered() uint64
- func (p *Player) GetPropertyString(name string) (string, error)
- func (p *Player) ImageSource() ui.ImageSource
- func (p *Player) NextChapter() error
- func (p *Player) Open(target string, opts ...OpenOptions) error
- func (p *Player) Pause() error
- func (p *Player) Play() error
- func (p *Player) PrevChapter() error
- func (p *Player) Screenshot(mode ...ScreenshotMode) (*image.RGBA, error)
- func (p *Player) Seek(pos time.Duration) error
- func (p *Player) SeekChapter(index int) error
- func (p *Player) SeekFast(pos time.Duration) error
- func (p *Player) SeekRelative(delta time.Duration) error
- func (p *Player) SelectAudioTrack(id int64) error
- func (p *Player) SelectSecondarySubtitleTrack(id int64) error
- func (p *Player) SelectSubtitleTrack(id int64) error
- func (p *Player) SetAudioDelay(d time.Duration) error
- func (p *Player) SetHTTPHeaders(headers map[string]string) error
- func (p *Player) SetHWDec(mode HWDecMode) error
- func (p *Player) SetLoop(loop bool) error
- func (p *Player) SetMaxSWRenderDim(maxDim int)
- func (p *Player) SetMuted(muted bool) error
- func (p *Player) SetPanscan(v float64) error
- func (p *Player) SetPreferredAudioLangs(langs ...string) error
- func (p *Player) SetPreferredSubLangs(langs ...string) error
- func (p *Player) SetPropertyString(name, value string) error
- func (p *Player) SetReferrer(ref string) error
- func (p *Player) SetRenderSize(width, height int)
- func (p *Player) SetSecondarySubtitleVisible(visible bool) error
- func (p *Player) SetSpeed(rate float64) error
- func (p *Player) SetSubtitleCodepage(codepage string) error
- func (p *Player) SetSubtitleDelay(d time.Duration) error
- func (p *Player) SetSubtitlePos(pos int) error
- func (p *Player) SetSubtitleScale(scale float64) error
- func (p *Player) SetSubtitleVisible(visible bool) error
- func (p *Player) SetUserAgent(ua string) error
- func (p *Player) SetVideoRotate(deg int) error
- func (p *Player) SetVolume(v float64) error
- func (p *Player) Snapshot() Snapshot
- func (p *Player) Stats() (PlaybackStats, error)
- func (p *Player) Stop() error
- func (p *Player) SubtitleTracks() []Track
- func (p *Player) Texture() *native.Texture
- func (p *Player) ToggleMute() error
- func (p *Player) TogglePause() error
- func (p *Player) Tracks() []Track
- func (p *Player) VideoTracks() []Track
- type QualityProfile
- type ScreenshotMode
- type Snapshot
- type State
- type SubtitleFlag
- type Track
- type TrackType
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("player: closed")
ErrClosed is returned when operations are invoked on a closed Player.
Functions ¶
func ClientAPIVersion ¶
ClientAPIVersion returns the loaded libmpv client API major and minor version.
func LanguageName ¶ added in v0.5.0
LanguageName returns the English name of an ISO 639-1 ("ja") or ISO 639-2 ("jpn"; both "ger" and "deu") language code as reported in track metadata, ignoring case and region suffixes ("pt-BR" is "Portuguese"). It knows about fifty widely used languages; other codes are returned upper-cased ("BN"), which still reads as a language code. Codes that name no single language ("und", "mul", "mis", "zxx") and empty codes return "", so that callers fall back to the track's title.
func LibraryPath ¶
LibraryPath returns the resolved path of the libmpv dynamic library.
func Load ¶
func Load() error
Load loads libmpv and binds all symbols once. New calls Load automatically; call Load earlier to verify libmpv availability at startup.
func SetLibraryPath ¶
func SetLibraryPath(path string)
SetLibraryPath overrides the libmpv shared library path before Load or New is called. Most applications should rely on mygo-plugin.json or MYGO_NATIVE_MPV instead.
func View ¶
View renders p's video frame inside MyGo's native UI scene graph (zero-copy Metal *native.Texture on macOS; double-buffered *ui.Bitmap on Windows and Linux). Because frames are composited directly in MyGo rather than a native child window, overlays such as danmaku, HUD controls, rounded corners, and popovers always render cleanly on top.
The returned ui.Element can be styled and laid out like any ui.Image (Fill, Width, Height, Radius, Opacity, etc.). View automatically binds the window's Invalidate hook to the player and reads the window's live display scale via ui.Painter.Scale() so both video and libass subtitles stay sharp across HiDPI/Retina and multi-monitor setups.
Aspect ratio and filling: View asks libmpv to render at the element's full physical size, and libmpv itself letterboxes the picture inside that frame (black bars) while drawing subtitles at full viewport resolution. The element's Fit(ui.Contain) therefore only matters before the first sized frame; overriding it with Fit(ui.Cover) does NOT remove libmpv's black bars (the frame already matches the element's size, bars included). To fill the viewport (crop-to-fill), keep the View full-size and call p.SetPanscan(1.0) (any value in 0..1 trades bars for cropping); SetVideoRotate rotates within the same frame.
Types ¶
type CacheRange ¶ added in v0.6.0
CacheRange represents a contiguous buffered time span in the demuxer cache.
type HWDecMode ¶
type HWDecMode string
HWDecMode controls hardware video decoding in libmpv.
const ( // HWDecAutoSafe enables safe zero-copy hardware decoding (VideoToolbox on // macOS) and falls back to software decoding for unsupported streams. HWDecAutoSafe HWDecMode = "auto-safe" // HWDecAutoCopy enables safe copy-back hardware decoding (such as D3D11VA on // Windows, VA-API/NVDEC on Linux, or VideoToolbox copy-back on macOS) and // falls back to software decoding for unsupported streams. Default on Windows // and Linux. HWDecAutoCopy HWDecMode = "auto-copy" // HWDecVideoToolbox explicitly requests Apple VideoToolbox zero-copy decoding. HWDecVideoToolbox HWDecMode = "videotoolbox" // HWDecVideoToolboxCopy requests VideoToolbox decoding with copy-back. HWDecVideoToolboxCopy HWDecMode = "videotoolbox-copy" // HWDecD3D11VACopy explicitly requests Windows D3D11VA hardware decoding with copy-back. HWDecD3D11VACopy HWDecMode = "d3d11va-copy" // HWDecVAAPICopy explicitly requests Linux VA-API hardware decoding with copy-back. HWDecVAAPICopy HWDecMode = "vaapi-copy" // HWDecNone disables hardware decoding (software decoding only). HWDecNone HWDecMode = "no" )
type OpenOptions ¶
type OpenOptions struct {
// Headers overrides or supplements HTTP headers for this media source.
// Per-open headers are automatically reset on subsequent Open calls.
Headers map[string]string
// UserAgent overrides the HTTP User-Agent for this media source.
UserAgent string
// Referrer overrides the HTTP Referer for this media source.
Referrer string
// StartTime seeks to the given position when opening the media.
StartTime time.Duration
// Paused opens the media paused on its first frame.
Paused bool
// Subtitles specifies external subtitle files to attach automatically.
Subtitles []string
}
OpenOptions configures per-file playback parameters passed to Player.Open.
type Options ¶
type Options struct {
// HWDec configures hardware decoding. Defaults to HWDecAutoSafe on macOS
// and HWDecAutoCopy on Windows and Linux.
HWDec HWDecMode
// Quality selects a built-in scaling and HDR tone-mapping preset
// (QualityDefault, QualityFast, QualityBalanced, QualityHigh).
Quality QualityProfile
// KeepOpen keeps the last frame visible when playback reaches EOF.
// Defaults to true when KeepOpen is nil.
KeepOpen *bool
// Volume sets initial volume in [0, 100] (or higher for software boost).
// Defaults to 100 when <= 0 (also with StartMuted, so unmuting is audible).
Volume float64
// StartMuted mutes audio on creation without changing Volume.
StartMuted bool
// Loop loops the current file indefinitely when true.
Loop bool
// PreferredAudioLangs sets ordered ISO 639 language codes for automatic
// audio track selection (e.g. []string{"jpn", "ja", "eng"}).
PreferredAudioLangs []string
// PreferredSubLangs sets ordered ISO 639 language codes for automatic
// subtitle track selection (e.g. []string{"zh", "chs", "sc", "chi", "eng"}).
PreferredSubLangs []string
// SubtitleCodepage sets libmpv's subtitle charset ("auto" by default,
// which uses uchardet when built in; or explicit encodings like "gb18030").
SubtitleCodepage string
// NetworkReconnect automatically configures FFmpeg HTTP(S) reconnection
// (reconnect=1,reconnect_streamed=1,reconnect_delay_max=5) for HTTP/HTTPS
// URLs so brief network drops recover seamlessly. Defaults to true when nil.
NetworkReconnect *bool
// MaxSWRenderDim caps the longest rendered dimension (in pixels) for the
// software render path (Windows/Linux) while preserving exact viewport
// aspect ratio. 0 (default) applies an automatic cap of
// max(video longest side, 1920) to avoid wasting CPU upscaling SD/HD video
// onto 4K/HiDPI displays; >0 sets an explicit pixel cap; <0 disables capping.
MaxSWRenderDim int
// PreventSleep uses mygo.Power.KeepAwake while playback is active (keeping
// the display awake for video, or the system awake for audio-only media)
// when running inside a MyGo App. Defaults to true when nil.
PreventSleep *bool
// PauseOnLockScreen automatically pauses active playback when the screen
// locks or the system suspends (via mygo.Power). Defaults to true when nil.
PauseOnLockScreen *bool
// HTTPHeaders sets default HTTP headers sent for network streams.
HTTPHeaders map[string]string
// UserAgent sets the default HTTP User-Agent for network streams.
UserAgent string
// Referrer sets the default HTTP Referer header for network streams.
Referrer string
// AudioOutput overrides mpv's "ao" option (e.g. "null" for headless tests).
// Defaults to "wasapi" on Windows and mpv's native default on macOS
// (CoreAudio) and Linux (PipeWire/PulseAudio/ALSA).
AudioOutput string
// LogLevel enables libmpv log callbacks ("fatal", "error", "warn", "info", "v", "debug").
// Empty disables log message delivery.
LogLevel string
// ExtraOptions sets arbitrary libmpv options before mpv_initialize.
ExtraOptions map[string]string
// OnLog receives libmpv log lines when LogLevel is set.
// Runs on the player's background event goroutine.
OnLog func(level, prefix, text string)
// OnStateChange is invoked when playback state, tracks, or metadata change.
// Position-only updates are throttled to about one call per 100ms (the
// Snapshot itself keeps full precision); state changes and seeks notify
// immediately. Usually runs on the player's background event goroutine
// (or the goroutine calling Open/Stop/track methods, after internal locks
// are released). Calling any Player method, including Close, is safe.
OnStateChange func()
// OnEndFile is invoked when playback of a file ends (EOF, stop, or error).
// With KeepOpen (default) the file stays loaded at EOF, so OnEndFile(nil)
// is delivered once when EOF is first reached; replaying (Play/seek back)
// or opening media re-arms it, and a later Stop/Open of the same ended
// file does not report it again. Errors carry a readable libmpv message.
// Runs on the player's background event goroutine; calling Close is safe.
OnEndFile func(err error)
}
Options configures a new Player created by New.
type PlaybackStats ¶ added in v0.6.0
type PlaybackStats struct {
FileFormat string
VideoCodec string
VideoWidth int
VideoHeight int
VideoFPS float64
EstimatedFPS float64
VideoBitrate int64
PixelFormat string
HWPixelFormat string
HWDec string
ColorMatrix string
ColorPrimaries string
ColorTransfer string
ColorLevels string
HDR bool
AudioCodec string
AudioChannels int
AudioSampleRate int
AudioBitrate int64
DroppedFrames int64
DecoderDrops int64
AVSync time.Duration
CacheDuration time.Duration
CacheBytes int64
CacheSpeed int64
}
PlaybackStats holds on-demand technical telemetry queried via Player.Stats.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player manages a libmpv playback instance rendered into MyGo's native UI scene graph (zero-copy native.Texture on macOS; double-buffered ui.Bitmap on Windows). Its methods are safe to call from any goroutine.
func (*Player) AddSubtitleFile ¶
func (p *Player) AddSubtitleFile(path string, flags ...SubtitleFlag) error
AddSubtitleFile attaches an external subtitle file (SRT, ASS/SSA, WebVTT, SUP, etc.). By default flag is SubtitleSelect so the added subtitle is immediately active.
func (*Player) AudioTracks ¶
AudioTracks returns all audio tracks in the current media.
func (*Player) Chapters ¶ added in v0.6.0
Chapters returns all chapters reported by libmpv for the current file.
func (*Player) Close ¶
Close shuts down the render context, event loop, and libmpv instance cleanly.
Close is idempotent and safe to call from any goroutine, including from inside OnStateChange / OnEndFile / OnLog callbacks running on the player's event goroutine. In that case Close returns immediately after stopping the renderer; the libmpv handle is destroyed as soon as the callback returns and the event loop unwinds, so no libmpv call ever touches a freed handle.
func (*Player) CurrentHWDec ¶
CurrentHWDec returns the active hardware decoder reported by libmpv (for example "videotoolbox", or "" / "no" when software decoding is active).
func (*Player) DisableAudioTrack ¶
DisableAudioTrack disables audio playback ("aid=no").
func (*Player) DisableSecondarySubtitleTrack ¶ added in v0.6.0
DisableSecondarySubtitleTrack turns off the secondary subtitle track ("secondary-sid=no").
func (*Player) DisableSubtitleTrack ¶
DisableSubtitleTrack turns off subtitle track selection ("sid=no").
func (*Player) FrameBackStep ¶ added in v0.4.0
FrameBackStep pauses playback and steps back exactly one video frame (requires a seekable source; it is slower than FrameStep).
func (*Player) FrameSize ¶ added in v0.2.0
FrameSize returns the pixel dimensions of the most recently rendered video frame on any supported platform.
func (*Player) FrameStep ¶ added in v0.4.0
FrameStep pauses playback and advances exactly one video frame.
func (*Player) FramesRendered ¶
FramesRendered returns the total number of video frames rendered since creation.
func (*Player) GetPropertyString ¶
GetPropertyString is an escape hatch for querying an arbitrary libmpv property.
func (*Player) ImageSource ¶ added in v0.2.0
func (p *Player) ImageSource() ui.ImageSource
ImageSource returns the ui.ImageSource for the current video frame (*native.Texture on macOS, *ui.Bitmap on Windows). Call it on the UI thread (typically via View(c, p)).
func (*Player) NextChapter ¶ added in v0.6.0
NextChapter advances to the next chapter in the current media.
func (*Player) Open ¶
func (p *Player) Open(target string, opts ...OpenOptions) error
Open opens a local file path or network URL for playback.
Open resets every per-file Snapshot field left over from the previous media (position, duration, EOF, buffering, title, video size, track IDs, tracks, error) and synchronizes Snapshot().Paused with opt.Paused immediately.
func (*Player) Play ¶
Play starts or resumes playback. If playback reached EOF it restarts from the beginning: with KeepOpen (default) it seeks back to 0; with KeepOpen=false (file already unloaded) it reloads the last opened target.
func (*Player) PrevChapter ¶ added in v0.6.0
PrevChapter jumps to the previous chapter in the current media.
func (*Player) Screenshot ¶ added in v0.6.0
func (p *Player) Screenshot(mode ...ScreenshotMode) (*image.RGBA, error)
Screenshot captures the current video frame in memory as an *image.RGBA without writing any temporary files to disk. By default mode is ScreenshotSubtitles (video with subtitles blended on top).
func (*Player) Seek ¶
Seek seeks to an exact absolute playback timestamp. For responsive scrubbing while a seek bar is dragged, call SeekFast during the drag and Seek on release.
func (*Player) SeekChapter ¶ added in v0.6.0
SeekChapter jumps to the zero-based chapter index in the current media.
func (*Player) SeekFast ¶ added in v0.6.0
SeekFast seeks to the nearest keyframe at pos ("absolute+keyframes"), avoiding full-GOP decoding stalls during interactive timeline scrubbing. Pair with Seek(pos) when the user releases the scrubber to land accurately.
func (*Player) SeekRelative ¶
SeekRelative seeks forward (positive) or backward (negative) by delta.
func (*Player) SelectAudioTrack ¶
SelectAudioTrack switches to the audio track with the given mpv track ID.
func (*Player) SelectSecondarySubtitleTrack ¶ added in v0.6.0
SelectSecondarySubtitleTrack enables a second simultaneous subtitle track (displayed at the top of the frame, useful for bilingual subtitles) and ensures secondary subtitle visibility is enabled.
func (*Player) SelectSubtitleTrack ¶
SelectSubtitleTrack switches to the embedded or external subtitle track with the given mpv track ID and ensures subtitle visibility is enabled.
func (*Player) SetAudioDelay ¶ added in v0.4.0
SetAudioDelay shifts audio relative to video by d (positive delays audio). Mirrored in Snapshot().AudioDelay.
func (*Player) SetHTTPHeaders ¶
SetHTTPHeaders sets default HTTP headers applied to subsequent network streams. Special headers "User-Agent" and "Referer"/"Referrer" are automatically mapped to libmpv's dedicated user-agent and referrer properties.
func (*Player) SetHWDec ¶
SetHWDec dynamically updates the hardware decoding mode (e.g. HWDecAutoSafe, HWDecAutoCopy, HWDecVideoToolbox, HWDecD3D11VACopy, HWDecNone).
func (*Player) SetMaxSWRenderDim ¶ added in v0.6.0
SetMaxSWRenderDim updates the longest-side pixel cap used by software renderers (Windows/Linux) while preserving exact viewport aspect ratio. 0 uses the automatic cap max(video longest side, 1920); >0 sets an explicit pixel limit; <0 disables capping. It is a no-op on GPU-rendered platforms.
func (*Player) SetPanscan ¶ added in v0.4.0
SetPanscan crops the video to fill the View's aspect ratio: 0 (default) letterboxes the whole picture, 1 fills the viewport completely (cropping edges). Values must be within [0, 1]. Because View renders at the full viewport size, subtitles stay sharp and inside the visible area. Mirrored in Snapshot().Panscan.
func (*Player) SetPreferredAudioLangs ¶ added in v0.6.0
SetPreferredAudioLangs sets ordered ISO 639 language codes used by libmpv when automatically selecting an audio track (e.g. "jpn", "ja", "eng").
func (*Player) SetPreferredSubLangs ¶ added in v0.6.0
SetPreferredSubLangs sets ordered ISO 639 language codes used by libmpv when automatically selecting a subtitle track (e.g. "zh", "chs", "sc", "eng").
func (*Player) SetPropertyString ¶
SetPropertyString is an escape hatch for setting an arbitrary libmpv property.
func (*Player) SetReferrer ¶
SetReferrer sets the default HTTP Referer header applied to network streams.
func (*Player) SetRenderSize ¶
SetRenderSize sets the target physical pixel dimensions for video rendering. Pass (0, 0) to revert to the video's native resolution.
func (*Player) SetSecondarySubtitleVisible ¶ added in v0.6.0
SetSecondarySubtitleVisible toggles secondary subtitle rendering without changing the selected secondary track.
func (*Player) SetSubtitleCodepage ¶ added in v0.6.0
SetSubtitleCodepage sets the character encoding libmpv uses when decoding non-UTF-8 external subtitles ("auto" for automatic uchardet detection, or an explicit iconv charset such as "gb18030", "big5", or "shift_jis").
func (*Player) SetSubtitleDelay ¶ added in v0.4.0
SetSubtitleDelay shifts subtitle timing by d (positive shows subtitles later). Mirrored in Snapshot().SubDelay.
func (*Player) SetSubtitlePos ¶ added in v0.4.0
SetSubtitlePos sets the vertical subtitle position in percent of the screen height (0 = top, 100 = bottom (default), up to 150 to push below the picture). Mirrored in Snapshot().SubPos.
func (*Player) SetSubtitleScale ¶ added in v0.4.0
SetSubtitleScale sets the subtitle font scale factor (must be > 0 and <= 100; default 1.0). Mirrored in Snapshot().SubScale.
func (*Player) SetSubtitleVisible ¶
SetSubtitleVisible toggles subtitle rendering without changing the selected track.
func (*Player) SetUserAgent ¶
SetUserAgent sets the default HTTP User-Agent applied to network streams.
func (*Player) SetVideoRotate ¶ added in v0.4.0
SetVideoRotate rotates the video clockwise by deg, which must be 0, 90, 180 or 270. Mirrored in Snapshot().VideoRotate. Arbitrary angles are not supported by this API; use SetPropertyString("video-rotate", ...) instead.
func (*Player) Snapshot ¶
Snapshot returns a consistent copy of the player's current playback state, tracks, chapters, and buffered cache ranges.
func (*Player) Stats ¶ added in v0.6.0
func (p *Player) Stats() (PlaybackStats, error)
Stats queries live technical playback telemetry (codecs, frame rates, drops, hardware decoding, color/HDR metadata, audio format, A/V sync, and cache state) on demand without adding per-frame event overhead.
func (*Player) Stop ¶
Stop stops playback and returns the player to idle, clearing every per-file Snapshot field (EOF, position, duration, buffering, title, video size, track IDs, tracks and error).
func (*Player) SubtitleTracks ¶
SubtitleTracks returns all embedded and external subtitle tracks in the current media.
func (*Player) Texture ¶
Texture returns the zero-copy GPU native.Texture on macOS, or nil on platforms that present frames through ui.Bitmap (such as Windows). Prefer View(c, p) or ImageSource() for cross-platform UI rendering.
func (*Player) ToggleMute ¶ added in v0.5.0
ToggleMute mutes or unmutes audio output based on libmpv's current state (not the asynchronously updated Snapshot), so calls made in quick succession each flip it. When unmuting a player whose volume is 0, it also restores an audible volume (50), so that unmuting is never silent.
func (*Player) TogglePause ¶
TogglePause switches between playing and paused states. When playback is paused or has reached EOF it calls Play (which restarts ended media). It decides from libmpv's current pause state rather than the asynchronously updated Snapshot, so calls made in quick succession each flip it.
func (*Player) VideoTracks ¶
VideoTracks returns all video tracks in the current media.
type QualityProfile ¶ added in v0.6.0
type QualityProfile string
QualityProfile selects a built-in video scaling and HDR tone-mapping preset. GPU-only options (such as libplacebo scalers and debanding) are applied on a best-effort basis so software-only libmpv builds ignore them cleanly.
const ( // QualityDefault enables balanced defaults: audio pitch correction on // speed changes, automatic HDR-to-SDR tone mapping, and automatic subtitle // charset detection. QualityDefault QualityProfile = "" // QualityFast favors lower GPU/CPU load (bilinear scaling, no debanding). QualityFast QualityProfile = "fast" // QualityBalanced enables sharp spline36/mitchell scaling and spline HDR // tone mapping with automatic peak detection. QualityBalanced QualityProfile = "balanced" // QualityHigh enables spline36/mitchell scaling, debanding, spline HDR // tone mapping, and automatic display ICC color management where supported. QualityHigh QualityProfile = "high" )
type ScreenshotMode ¶ added in v0.6.0
type ScreenshotMode string
ScreenshotMode controls what layers Player.Screenshot captures.
const ( // ScreenshotSubtitles captures the video frame with subtitles rendered on // top (default). ScreenshotSubtitles ScreenshotMode = "subtitles" // ScreenshotVideo captures the raw video frame without subtitles or OSD. ScreenshotVideo ScreenshotMode = "video" // ScreenshotWindow captures the rendered viewport output including scaling, // letterboxing, and subtitles. ScreenshotWindow ScreenshotMode = "window" )
type Snapshot ¶
type Snapshot struct {
State State
Position time.Duration
Duration time.Duration
Volume float64
Muted bool
Speed float64
Paused bool
Buffering bool
EOF bool
VideoWidth int
VideoHeight int
CurrentHWDec string
MediaTitle string
AudioTrackID int64
SubTrackID int64
SubVisible bool
SecondarySubTrackID int64
SecondarySubVisible bool
Tracks []Track
Chapter int
Chapters []Chapter
CacheDuration time.Duration
CachedRanges []CacheRange
Err error
// SubDelay is the subtitle delay (see SetSubtitleDelay).
SubDelay time.Duration
// AudioDelay is the audio delay (see SetAudioDelay).
AudioDelay time.Duration
// SubScale is the subtitle scale factor (default 1.0).
SubScale float64
// SubPos is the vertical subtitle position in percent (default 100).
SubPos int
// VideoRotate is the clockwise video rotation in degrees.
VideoRotate int
// Panscan is the crop-to-fill amount in [0, 1] (see SetPanscan).
Panscan float64
// Seekable reports whether libmpv can seek in the current media (false
// for most live streams, and until the file is loaded).
Seekable bool
}
Snapshot is an immutable point-in-time summary of player state suitable for reading in UI view functions without taking locks repeatedly.
type SubtitleFlag ¶
type SubtitleFlag string
SubtitleFlag controls how AddSubtitleFile treats a newly added subtitle track.
const ( // SubtitleSelect loads and immediately activates the subtitle track (default). SubtitleSelect SubtitleFlag = "select" // SubtitleAuto loads the subtitle track without overriding an active track. SubtitleAuto SubtitleFlag = "auto" // SubtitleCached loads the subtitle track without selecting it. SubtitleCached SubtitleFlag = "cached" )
type Track ¶
type Track struct {
ID int64
Type TrackType
SrcID int64
Title string
Lang string
Codec string
Selected bool
Default bool
Forced bool
External bool
ExternalFilename string
Width int
Height int
FPS float64
Channels int
SampleRate int
}
Track describes a video, audio, or subtitle stream reported by libmpv.
func (Track) DisplayName ¶ added in v0.5.0
DisplayName returns a short human-readable name for the track, suitable for menus: the language spelled out ("Japanese" for "jpn" or "ja"), the track title when it adds something, and "Forced" for forced subtitles, joined with " · ". External subtitle files without a meaningful title fall back to their file name. Tracks with no language, title, or file name are named "Track N" by their libmpv ID. Codec and ID details are left out on purpose; callers that show several tracks with the same name can append them to tell the tracks apart.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
player
command
Example player demonstrates github.com/arixbit/mygo-player in a MyGo native UI window on macOS (zero-copy IOSurface -> Metal), Windows and Linux (software render API -> ui.Bitmap): MKV playback, multi-audio track switching, embedded & external subtitles, and custom HTTP headers, behind a control bar that stays out of the way of the picture.
|
Example player demonstrates github.com/arixbit/mygo-player in a MyGo native UI window on macOS (zero-copy IOSurface -> Metal), Windows and Linux (software render API -> ui.Bitmap): MKV playback, multi-audio track switching, embedded & external subtitles, and custom HTTP headers, behind a control bar that stays out of the way of the picture. |
|
internal
|
|
|
scripts
|
|
|
update-manifest
command
Command update-manifest updates mygo-plugin.json with SHA-256 checksums and immutable release asset URLs for built libmpv dynamic libraries, matching MyGo's native library publishing convention.
|
Command update-manifest updates mygo-plugin.json with SHA-256 checksums and immutable release asset URLs for built libmpv dynamic libraries, matching MyGo's native library publishing convention. |
