bugfix
This commit is contained in:
parent
87cd36ffba
commit
cb4c5f25ec
@ -1,3 +1,4 @@
|
||||
import time
|
||||
from kivy.uix.video import Video
|
||||
from kivy.logger import Logger
|
||||
from kivy.core.window import Window
|
||||
@ -49,3 +50,48 @@ class NewVideo(BGColorBehavior, Video):
|
||||
if video.position is None:
|
||||
return
|
||||
super()._on_video_frame(*largs)
|
||||
|
||||
#
|
||||
# try to fix up the error
|
||||
def unload(self,try_cnt=0):
|
||||
"""
|
||||
Traceback (most recent call last):
|
||||
File "main.py", line 288, in <module>
|
||||
myapp.run()
|
||||
File "C:\Python37\lib\site-packages\kivy\app.py", line 855, in run
|
||||
runTouchApp()
|
||||
File "C:\Python37\lib\site-packages\kivy\base.py", line 504, in runTouchApp
|
||||
EventLoop.window.mainloop()
|
||||
File "C:\Python37\lib\site-packages\kivy\core\window\window_sdl2.py", line 747, in mainloop
|
||||
self._mainloop()
|
||||
File "C:\Python37\lib\site-packages\kivy\core\window\window_sdl2.py", line 479, in _mainloop
|
||||
EventLoop.idle()
|
||||
File "C:\Python37\lib\site-packages\kivy\base.py", line 348, in idle
|
||||
Clock.tick_draw()
|
||||
File "C:\Python37\lib\site-packages\kivy\clock.py", line 598, in tick_draw
|
||||
self._process_events_before_frame()
|
||||
File "kivy\_clock.pyx", line 427, in kivy._clock.CyClockBase._process_events_before_frame
|
||||
File "kivy\_clock.pyx", line 467, in kivy._clock.CyClockBase._process_events_before_frame
|
||||
File "kivy\_clock.pyx", line 465, in kivy._clock.CyClockBase._process_events_before_frame
|
||||
File "kivy\_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
|
||||
File "C:\Python37\lib\site-packages\kivy\uix\video.py", line 174, in _do_video_load
|
||||
self.unload()
|
||||
File "C:\Python37\lib\site-packages\kivy\uix\video.py", line 240, in unload
|
||||
self._video.stop()
|
||||
File "C:\Python37\lib\site-packages\kivy\core\video\video_ffpyplayer.py", line 325, in stop
|
||||
self.unload()
|
||||
File "C:\Python37\lib\site-packages\kivy\core\video\video_ffpyplayer.py", line 366, in unload
|
||||
self._thread.join()
|
||||
File "C:\Python37\lib\threading.py", line 1039, in join
|
||||
raise RuntimeError("cannot join thread before it is started")
|
||||
RuntimeError: cannot join thread before it is started
|
||||
"""
|
||||
try:
|
||||
super().unload()
|
||||
return
|
||||
except Exception as e:
|
||||
if try_cnt > 3:
|
||||
print('video.unload() tried 3 time,still error....',e)
|
||||
raise e
|
||||
time.sleep(0.1)
|
||||
return unload(try_cnt+1)
|
||||
|
@ -23,6 +23,8 @@ class OrientationLayout(WidgetReady, SwipeBehavior, FloatLayout):
|
||||
Clock.schedule_once(self.build_children,0)
|
||||
self.bind(on_swipe_left=self.toggle_second)
|
||||
self.bind(on_swipe_right=self.toggle_second)
|
||||
self.bind(size=self.on_size_changed)
|
||||
self.bind(pos=self.on_size_changed)
|
||||
|
||||
def build_children(self, *args):
|
||||
if isinstance(self.main_widget, dict):
|
||||
@ -40,26 +42,16 @@ class OrientationLayout(WidgetReady, SwipeBehavior, FloatLayout):
|
||||
return self.width > self.height
|
||||
|
||||
def toggle_second(self,*args):
|
||||
print('toggle_second() called ..')
|
||||
if self.isLandscape():
|
||||
if self.second_flg:
|
||||
print('remove second widget ..')
|
||||
self.remove_widget(self.widget_second)
|
||||
self.second_flg = False
|
||||
else:
|
||||
print('add second widget ..',self.widget_second)
|
||||
self.add_widget(self.widget_second)
|
||||
self.second_flg = True
|
||||
self.on_size(self.size)
|
||||
self.on_size_changed(self.size)
|
||||
|
||||
|
||||
def on_ready(self,*args):
|
||||
Clock.schedule_once(self.two_widget_layout,0)
|
||||
|
||||
def on_size(self,*args):
|
||||
Clock.schedule_once(self.two_widget_layout,0)
|
||||
|
||||
def on_pos(self,*args):
|
||||
def on_size_changed(self,*args):
|
||||
Clock.schedule_once(self.two_widget_layout,0)
|
||||
|
||||
def two_widget_layout(self, *args):
|
||||
@ -71,46 +63,35 @@ class OrientationLayout(WidgetReady, SwipeBehavior, FloatLayout):
|
||||
self.horizontal_layout()
|
||||
else:
|
||||
self.vertical_layout()
|
||||
self.do_layout()
|
||||
|
||||
def horizontal_layout(self):
|
||||
self.widget_main.size_hint_x = 1
|
||||
self.widget_main.size_hint_y = 1
|
||||
self.widget_main.size_hint = (None,None)
|
||||
self.widget_main.size = self.size
|
||||
self.widget_main.pos = self.pos
|
||||
self.widget_second.height = self.height
|
||||
self.widget_second.size_hint_x = None
|
||||
self.widget_second.size_hint_y = 1
|
||||
self.widget_second.size_hint = (None,None)
|
||||
self.widget_second.width = self.width * self.height / self.width
|
||||
self.widget_second.pos = (0,0)
|
||||
self.widget_second.opacity = 0.6
|
||||
if not self.widget_main in self.children:
|
||||
print('horizontal:main_widget:width=%.02f,height=%.02f,pos=(%.02f,%.02f)' % (self.widget_main.width,self.widget_main.height,*self.widget_main.pos))
|
||||
self.add_widget(self.widget_main)
|
||||
if self.widget_second in self.children:
|
||||
self.remove_widget(self.widget_second)
|
||||
print('horizontal:second_widget:width=%.02f,height=%.02f,pos=(%.02f,%.02f)' % (self.widget_second.width,self.widget_second.height,*self.widget_second.pos))
|
||||
self.clear_widgets()
|
||||
self.add_widget(self.widget_main)
|
||||
if self.second_flg:
|
||||
self.add_widget(self.widget_second)
|
||||
|
||||
|
||||
def vertical_layout(self):
|
||||
self.widget_main.size_hint_x = 1
|
||||
self.widget_main.size_hint_y = None
|
||||
self.widget_main.width = self.width
|
||||
self.widget_main.height = self.width / 16 * 10
|
||||
self.widget_main.size_hint = (None,None)
|
||||
self.widget_main.size = (self.width, \
|
||||
self.width / 16 * 10)
|
||||
self.widget_main.pos = (0, self.height - self.widget_main.height)
|
||||
self.widget_second.width = self.width
|
||||
self.widget_second.size_hint_x = 1
|
||||
self.widget_second.size_hint_y = None
|
||||
self.widget_second.height = self.height - self.widget_main.height
|
||||
self.widget_second.size_hint = (None, None)
|
||||
self.widget_second.size = (self.width, \
|
||||
self.height - self.widget_main.height)
|
||||
self.widget_second.pos = (0,0)
|
||||
self.widget_second.opacity = 1
|
||||
if not self.widget_main in self.children:
|
||||
self.add_widget(self.widget_main)
|
||||
print('vertical:main_widget:width=%.02f,height=%.02f,pos=(%.02f,%.02f)' % (self.widget_main.width,self.widget_main.height,*self.widget_main.pos))
|
||||
if not self.widget_second in self.children:
|
||||
self.add_widget(self.widget_second)
|
||||
print('vertical:second_widget:width=%.02f,height=%.02f,pos=(%.02f,%.02f)' % (self.widget_second.width,self.widget_second.height,*self.widget_second.pos))
|
||||
self.widget_second.opacity = 0.6
|
||||
self.clear_widgets()
|
||||
self.add_widget(self.widget_main)
|
||||
self.add_widget(self.widget_second)
|
||||
|
||||
def main_widget_built(self,o,w):
|
||||
print('main_widget_built() called ...')
|
||||
|
Loading…
Reference in New Issue
Block a user