This commit is contained in:
yumoqing 2022-09-03 00:05:02 +08:00
parent 33c728a550
commit ce2d56016f
4 changed files with 19 additions and 10 deletions

View File

@ -262,6 +262,10 @@ class Modal(VBox):
def __init__(self, **kw): def __init__(self, **kw):
SUPER(Modal, self, kw) SUPER(Modal, self, kw)
self.register_event_type('on_open')
self.register_event_type('on_pre_open')
self.register_event_type('on_pre_dismiss')
self.register_event_type('on_dismiss')
if self.content: if self.content:
blocks = Factory.Blocks() blocks = Factory.Blocks()
self.content_w = blocks.widgetBuild(self.content) self.content_w = blocks.widgetBuild(self.content)
@ -269,10 +273,6 @@ class Modal(VBox):
self.add_widget(self.content_w) self.add_widget(self.content_w)
else: else:
print(content,':cannot build widget') print(content,':cannot build widget')
self.register_event_type('on_open')
self.register_event_type('on_pre_open')
self.register_event_type('on_pre_dismiss')
self.register_event_type('on_dismiss')
def on_touch_down(self, touch): def on_touch_down(self, touch):
if not self.collide_point(touch.x, touch.y): if not self.collide_point(touch.x, touch.y):
@ -333,7 +333,6 @@ class Modal(VBox):
def add_widget(self, w, *args, **kw): def add_widget(self, w, *args, **kw):
super().add_widget(w, *args, **kw) super().add_widget(w, *args, **kw)
# super().add_widget(Label(text='1111'))
if self.auto_open: if self.auto_open:
self.open() self.open()

View File

@ -415,7 +415,7 @@ class Blocks(EventDispatcher):
p.update(d) p.update(d)
opts['options'] = p opts['options'] = p
def doit(target:Widget, add_mode:str, o, w:Widget): def doit(target:Widget, add_mode:str, o, w:Widget):
if isinstance(w, ModalView): if isinstance(w, Modal):
return return
if target and not w.parent: if target and not w.parent:

View File

@ -32,6 +32,8 @@ class FFVideo(WidgetReady, Image):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self._player = None self._player = None
self._volume = 0
self._position = 0
self._update_task = None self._update_task = None
self._texture = None self._texture = None
self.is_black = False self.is_black = False
@ -98,6 +100,7 @@ class FFVideo(WidgetReady, Image):
return return
self._player.set_volume(self.volume) self._player.set_volume(self.volume)
self._volume = self.volume
def on_status(self, *args): def on_status(self, *args):
print('on_status called, ', self.status) print('on_status called, ', self.status)
@ -113,11 +116,17 @@ class FFVideo(WidgetReady, Image):
else: else:
pass pass
def on_parent(self, *args):
if self.parent:
return
self._play_stop()
del self
def on_frame(self, *args): def on_frame(self, *args):
if self._player is None: if self._player is None:
return return
# self._player.request_channel(self, 'audio', 'open', self.audio_id) # self._player.request_channel(self, 'audio', 'open', self.audio_id)
p = self._player.get_pts() / self.duration * self.width p = self._position / self.duration * self.width
with self.canvas.after: with self.canvas.after:
Color(1,1,1,1) Color(1,1,1,1)
Line() Line()
@ -154,7 +163,7 @@ class FFVideo(WidgetReady, Image):
if self.status != 'play': if self.status != 'play':
return return
self._player.seek(pts) self._player.seek(pts)
self.position = self._player.get_pts() self._position = self._player.get_pts()
def mute(self, flag): def mute(self, flag):
if self.play_mode == 'preview': if self.play_mode == 'preview':
@ -330,7 +339,8 @@ class FFVideo(WidgetReady, Image):
self._get_video_info() self._get_video_info()
self.timepass += self.timeperiod self.timepass += self.timeperiod
self.position = self._player.get_pts() self._position = self._player.get_pts()
self._volume = self._player.get_volume()
if self.timepass < self.video_ts: if self.timepass < self.video_ts:
return return

View File

@ -1 +1 @@
__version__ = '0.3.1' __version__ = '0.3.2'