2014-08-01 23:35:39 +00:00
|
|
|
-- Test script for property change notification mechanism.
|
2015-01-03 13:49:48 +00:00
|
|
|
-- 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.
|
2014-08-01 23:35:39 +00:00
|
|
|
|
2014-11-28 22:18:50 +00:00
|
|
|
local utils = require("mp.utils")
|
2014-08-01 23:35:39 +00:00
|
|
|
|
2024-05-27 21:10:18 +00:00
|
|
|
local function observe(name)
|
2024-05-12 00:13:06 +00:00
|
|
|
mp.observe_property(name, "native", function(prop, val)
|
|
|
|
print("property '" .. prop .. "' changed to '" ..
|
2014-11-28 22:18:50 +00:00
|
|
|
utils.to_string(val) .. "'")
|
2014-08-01 23:35:39 +00:00
|
|
|
end)
|
|
|
|
end
|
2016-09-23 18:49:23 +00:00
|
|
|
|
2024-05-12 00:13:06 +00:00
|
|
|
for _, name in ipairs(mp.get_property_native("property-list")) do
|
2016-09-23 18:49:23 +00:00
|
|
|
observe(name)
|
|
|
|
end
|
|
|
|
|
2024-05-12 00:13:06 +00:00
|
|
|
for _, name in ipairs(mp.get_property_native("options")) do
|
2016-09-23 18:49:23 +00:00
|
|
|
observe("options/" .. name)
|
|
|
|
end
|