Commit ba21209
committed
osc: define and add support for "preview" api
this adds a "standard" api for ui scripts and thumbnailers to
communicate with each other, based on the simple thumbfast api
[1].
the api works as follows:
* To issue a thumbnail draw command, the UI script will set the property
`user-data/osc/draw-preview` with `hover_sec`, `x`, `y`, `w`
and `h` field set. hover_sec is the position in seconds where
the user is hovering. x and y are top-left coordinates to draw
the thumbnail in and `w` and `h` are width and height of the
size to draw the thumbnail at (the actual backing thumbnail
size may be different). x,y,w,h must be positive integers.
* To clear the thumbnail, the UI script will set the previously
mentioned property to `nil`.
a more ideal api would make it so that the thumbnailer script
only generates the thumbnail and doesn't need to draw at all.
but this is a decent enough api that allows arbitrary
thumbnailers and ui scripts to communicate between each other
and work together.
this change has been tested with work with thumbfast (using the
"thumbfast-glue" script [4]). and for demonstration that this
api can be useful outside of osc, it has also been tested to
work on mfpbar's thumbnailer branch [3].
the code to determine thumbnail x,y is based on the osc fork
inside of thumbfast [2].
[1]: https://github.com/po5/thumbfast?tab=readme-ov-file#for-ui-developers-how-to-add-thumbfast-support-to-your-script
[2]: https://github.com/po5/thumbfast/tree/vanilla-osc
[3]: https://codeberg.org/NRK/mpv-toolbox/src/branch/thumbnailer/mfpbar
[4]: mpv-player#17518 (comment)1 parent 4f9f1ff commit ba21209
3 files changed
Lines changed: 93 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3951 | 3951 | | |
3952 | 3952 | | |
3953 | 3953 | | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
3954 | 3958 | | |
3955 | 3959 | | |
3956 | 3960 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
591 | 597 | | |
592 | 598 | | |
593 | 599 | | |
| |||
721 | 727 | | |
722 | 728 | | |
723 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
1156 | 1158 | | |
1157 | 1159 | | |
1158 | 1160 | | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1159 | 1208 | | |
1160 | 1209 | | |
1161 | 1210 | | |
| |||
3170 | 3219 | | |
3171 | 3220 | | |
3172 | 3221 | | |
| 3222 | + | |
3173 | 3223 | | |
3174 | 3224 | | |
3175 | 3225 | | |
| |||
0 commit comments