File: observe-all.lua

package info (click to toggle)
mpv 0.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,676 kB
  • sloc: ansic: 152,062; python: 1,228; sh: 646; javascript: 612; cpp: 461; objc: 302; pascal: 49; xml: 29; makefile: 19
file content (22 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Test script for property change notification mechanism.
-- Note that watching/reading some properties can be very expensive, or
-- require the player to synchronously wait on network (when playing
-- remote files), so you should in general only watch properties you
-- are interested in.

local utils = require("mp.utils")

local function observe(name)
    mp.observe_property(name, "native", function(prop, val)
        print("property '" .. prop .. "' changed to '" ..
              utils.to_string(val) .. "'")
    end)
end

for _, name in ipairs(mp.get_property_native("property-list")) do
    observe(name)
end

for _, name in ipairs(mp.get_property_native("options")) do
    observe("options/" .. name)
end