File: observe-all.lua

package info (click to toggle)
mpv 0.41.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,404 kB
  • sloc: ansic: 155,875; python: 1,235; sh: 643; javascript: 612; cpp: 468; objc: 302; pascal: 49; xml: 29; makefile: 18
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