Hook enum
Lifecycle hook fired by mpv during file loading and unloading.
Six phases you can intercept to lazily resolve a URL, attach per-file HTTP headers, drive a fallback path, or react to a track boundary.
Pass to Player.registerHook to subscribe; the matching MpvHookEvent arrives on PlayerStream.hook.
player.registerHook(Hook.load);
player.stream.hook.listen((event) async {
switch (event.hook) {
case Hook.load:
// Redirect the URL via stream-open-filename, attach
// file-local-options/http-header-fields, etc.
default:
}
player.continueHook(event.id); // always call, even on error
});
Values
- beforeStartFile → const Hook
-
Before any per-file work begins. Drains any pending property changes from the previous file before the new
start-fileevent fires.const Hook('on_before_start_file') - load → const Hook
-
Before a stream is opened. The most common interception point — rewrite
stream-open-filenameto redirect the URL, or setfile-local-options/http-header-fieldsto attach per-file HTTP headers.const Hook('on_load') - loadFail → const Hook
-
After a stream failed to open. Useful for fallback URLs: rewrite
stream-open-filenameand mpv will retry.const Hook('on_load_fail') - preloaded → const Hook
-
File open, demuxer ready, but track selection and decoder init haven't run yet. Last chance to influence track choice via mpv's selection properties (
aid,vid,sid).const Hook('on_preloaded') - unload → const Hook
-
Before a file is closed. Cleanup hook for resources tied to the current file. Cannot resume playback from this state.
const Hook('on_unload') - afterEndFile → const Hook
-
After a file finished and was fully unloaded. The next file (if any) hasn't started yet.
const Hook('on_after_end_file')
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- mpvValue → String
-
The wire-level name mpv expects in
mpv_hook_add().final - name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited