Make compatible with libmpv 0.22.0
This commit is contained in:
parent
03492ba394
commit
a80f638732
2 changed files with 16 additions and 16 deletions
15
mpv-test.py
15
mpv-test.py
|
|
@ -64,7 +64,8 @@ class TestProperties(unittest.TestCase):
|
||||||
continue # Property seems to be an aliased option
|
continue # Property seems to be an aliased option
|
||||||
if prop in ('ad-spdif-dtshd', 'softvol', 'heartbeat-cmd', 'input-x11-keyboard',
|
if prop in ('ad-spdif-dtshd', 'softvol', 'heartbeat-cmd', 'input-x11-keyboard',
|
||||||
'vo-vdpau-queuetime-windowed', 'demuxer-max-packets', '3dlut-size', 'right-alt-gr',
|
'vo-vdpau-queuetime-windowed', 'demuxer-max-packets', '3dlut-size', 'right-alt-gr',
|
||||||
'mkv-subtitle-preroll', 'dtshd', 'softvol-max'):
|
'mkv-subtitle-preroll', 'dtshd', 'softvol-max', 'pulse-sink',
|
||||||
|
'alsa-device', 'oss-device', 'ao-defaults', 'vo-defaults'):
|
||||||
continue # Property seems to be an aliased option that was forgotten in MPV.options
|
continue # Property seems to be an aliased option that was forgotten in MPV.options
|
||||||
prop = prop.replace('-', '_')
|
prop = prop.replace('-', '_')
|
||||||
self.assertTrue(prop in ledir, 'Property {} not found'.format(prop))
|
self.assertTrue(prop in ledir, 'Property {} not found'.format(prop))
|
||||||
|
|
@ -100,13 +101,15 @@ class TestProperties(unittest.TestCase):
|
||||||
mpv.ErrorCode.PROPERTY_FORMAT,
|
mpv.ErrorCode.PROPERTY_FORMAT,
|
||||||
mpv.ErrorCode.PROPERTY_NOT_FOUND]): # This is due to a bug with option-mapped properties in mpv 0.18.1
|
mpv.ErrorCode.PROPERTY_NOT_FOUND]): # This is due to a bug with option-mapped properties in mpv 0.18.1
|
||||||
if ptype == int:
|
if ptype == int:
|
||||||
setattr(self.m, name, 0)
|
setattr(self.m, name, 100)
|
||||||
setattr(self.m, name, 1)
|
setattr(self.m, name, 1)
|
||||||
|
setattr(self.m, name, 0)
|
||||||
setattr(self.m, name, -1)
|
setattr(self.m, name, -1)
|
||||||
elif ptype == float:
|
elif ptype == float:
|
||||||
setattr(self.m, name, 0.0)
|
# Some properties have range checks done on their values
|
||||||
setattr(self.m, name, 1)
|
setattr(self.m, name, 1)
|
||||||
setattr(self.m, name, 1.0)
|
setattr(self.m, name, 1.0)
|
||||||
|
setattr(self.m, name, 0.0)
|
||||||
setattr(self.m, name, -1.0)
|
setattr(self.m, name, -1.0)
|
||||||
setattr(self.m, name, float('nan'))
|
setattr(self.m, name, float('nan'))
|
||||||
elif ptype == str:
|
elif ptype == str:
|
||||||
|
|
@ -158,7 +161,7 @@ class ObservePropertyTest(unittest.TestCase):
|
||||||
m.loop = 'no'
|
m.loop = 'no'
|
||||||
m.loop = 'inf'
|
m.loop = 'inf'
|
||||||
m.terminate() # needed for synchronization of event thread
|
m.terminate() # needed for synchronization of event thread
|
||||||
handler.assert_has_calls([mock.call('loop', 'no'), mock.call('loop', 'inf')])
|
handler.assert_has_calls([mock.call('loop', False), mock.call('loop', 'inf')])
|
||||||
|
|
||||||
def test_property_observer_decorator(self):
|
def test_property_observer_decorator(self):
|
||||||
handler = mock.Mock()
|
handler = mock.Mock()
|
||||||
|
|
@ -186,7 +189,7 @@ class ObservePropertyTest(unittest.TestCase):
|
||||||
# which these properties were previously accessed. Thus, any_order.
|
# which these properties were previously accessed. Thus, any_order.
|
||||||
handler.assert_has_calls([
|
handler.assert_has_calls([
|
||||||
mock.call('mute', False),
|
mock.call('mute', False),
|
||||||
mock.call('loop', 'no')],
|
mock.call('loop', False)],
|
||||||
any_order=True)
|
any_order=True)
|
||||||
handler.reset_mock()
|
handler.reset_mock()
|
||||||
|
|
||||||
|
|
@ -318,7 +321,7 @@ class RegressionTests(unittest.TestCase):
|
||||||
m.loop = 'no'
|
m.loop = 'no'
|
||||||
m.loop = 'inf'
|
m.loop = 'inf'
|
||||||
m.terminate() # needed for synchronization of event thread
|
m.terminate() # needed for synchronization of event thread
|
||||||
handler.assert_has_calls([mock.call('loop', 'no'), mock.call('loop', 'inf')])
|
handler.assert_has_calls([mock.call('loop', False), mock.call('loop', 'inf')])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
17
mpv.py
17
mpv.py
|
|
@ -971,17 +971,14 @@ class MPV(object):
|
||||||
|
|
||||||
def _set_property(self, name, value, proptype=str):
|
def _set_property(self, name, value, proptype=str):
|
||||||
ename = name.encode('utf-8')
|
ename = name.encode('utf-8')
|
||||||
try:
|
if proptype is MpvFormat.NODE:
|
||||||
if proptype is MpvFormat.NODE:
|
if isinstance(value, (list, set, dict)):
|
||||||
if isinstance(value, (list, set, dict)):
|
_1, _2, _3, pointer = _make_node_str_list(value)
|
||||||
_1, _2, _3, pointer = _make_node_str_list(value)
|
_mpv_set_property(self.handle, ename, MpvFormat.NODE, pointer)
|
||||||
_mpv_set_property(self.handle, ename, MpvFormat.NODE, pointer)
|
|
||||||
else:
|
|
||||||
_mpv_set_property_string(self.handle, ename, _mpv_coax_proptype(value, str))
|
|
||||||
else:
|
else:
|
||||||
_mpv_set_property_string(self.handle, ename, _mpv_coax_proptype(value, proptype))
|
_mpv_set_property_string(self.handle, ename, _mpv_coax_proptype(value, str))
|
||||||
except TypeError as e:
|
else:
|
||||||
raise TypeError("Error setting MPV {} property {}".format(proptype, name)) from e
|
_mpv_set_property_string(self.handle, ename, _mpv_coax_proptype(value, proptype))
|
||||||
|
|
||||||
# Dict-like option access
|
# Dict-like option access
|
||||||
def __getitem__(self, name, file_local=False):
|
def __getitem__(self, name, file_local=False):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue