'bugfix'
This commit is contained in:
parent
1ee4a4adaa
commit
8b537c8cdc
@ -64,60 +64,53 @@ def signal_handler(signal, frame):
|
|||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
def on_close(o,v=None):
|
||||||
|
"""
|
||||||
|
catch the "x" button's event of window
|
||||||
|
"""
|
||||||
|
app = App.get_running_app()
|
||||||
|
app.workers.running = False
|
||||||
|
|
||||||
|
def getAuthHeader():
|
||||||
|
app = App.get_running_app()
|
||||||
|
if not hasattr(app,'serverinfo'):
|
||||||
|
print('app serverinfo not found')
|
||||||
|
return {}
|
||||||
|
serverinfo = app.serverinfo
|
||||||
|
if hasattr(serverinfo,'authCode'):
|
||||||
|
return {
|
||||||
|
'authorization':serverinfo.authCode
|
||||||
|
}
|
||||||
|
print('serverinfo authCode not found')
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def closeWorkers():
|
||||||
|
app = App.get_running_app()
|
||||||
|
app.workers.running = False
|
||||||
|
|
||||||
|
def appBlocksHack(app):
|
||||||
|
config = getConfig()
|
||||||
|
app.on_close = on_close
|
||||||
|
app.getAuthHeader = getAuthHeader
|
||||||
|
app.__del__ = closeWorkers
|
||||||
|
Window.bind(on_request_close=app.on_close)
|
||||||
|
app.serverinfo = ServerInfo()
|
||||||
|
app.title = 'Test Title'
|
||||||
|
app.blocks = Blocks()
|
||||||
|
app.workers = Workers(maxworkers=config.maxworkers or 80)
|
||||||
|
app.workers.start()
|
||||||
|
app.hc = HttpClient()
|
||||||
|
WindowBase.softinput_mode='below_target'
|
||||||
|
|
||||||
class BlocksApp(App):
|
class BlocksApp(App):
|
||||||
def build(self):
|
def build(self):
|
||||||
config = getConfig()
|
root = PageContainer()
|
||||||
self.config = config
|
|
||||||
# self.theme_cls = ThemeManager()
|
|
||||||
self.serverinfo = ServerInfo()
|
|
||||||
self.title = 'Test Title'
|
|
||||||
self.blocks = Blocks()
|
|
||||||
self.workers = Workers(maxworkers=config.maxworkers or 80)
|
|
||||||
Window.bind(on_request_close=self.on_close)
|
|
||||||
self.workers.start()
|
|
||||||
self.hc = HttpClient()
|
|
||||||
WindowBase.softinput_mode='below_target'
|
|
||||||
x = PageContainer()
|
|
||||||
Clock.schedule_once(self.build1)
|
|
||||||
print('build() called......')
|
|
||||||
return x
|
|
||||||
|
|
||||||
def getAuthHeader(self):
|
|
||||||
if not hasattr(self,'serverinfo'):
|
|
||||||
print('app serverinfo not found')
|
|
||||||
return {}
|
|
||||||
serverinfo = self.serverinfo
|
|
||||||
if hasattr(serverinfo,'authCode'):
|
|
||||||
return {
|
|
||||||
'authorization':serverinfo.authCode
|
|
||||||
}
|
|
||||||
print('serverinfo authCode not found')
|
|
||||||
return {}
|
|
||||||
|
|
||||||
def on_start(self):
|
|
||||||
print('on_start() called ...')
|
|
||||||
|
|
||||||
def build1(self,t):
|
|
||||||
x = None
|
x = None
|
||||||
x = self.blocks.widgetBuild(self.config.root)
|
config = getConfig()
|
||||||
|
x = self.blocks.widgetBuild(config.root)
|
||||||
if x is None:
|
if x is None:
|
||||||
alert(str(self.config.root)+': cannt build widget')
|
alert(str(self.config.root)+': cannt build widget')
|
||||||
return
|
return root
|
||||||
self.root.add_widget(x)
|
root.add_widget(x)
|
||||||
return
|
return root
|
||||||
|
|
||||||
def on_close(self,o,v=None):
|
|
||||||
"""
|
|
||||||
catch the "x" button's event of window
|
|
||||||
"""
|
|
||||||
self.workers.running = False
|
|
||||||
|
|
||||||
def on_pause(self,o,v=None):
|
|
||||||
"""
|
|
||||||
to avoid app start from beginening when user exit and reenter this app
|
|
||||||
"""
|
|
||||||
return True
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self.workers.running = False
|
|
||||||
|
@ -14,9 +14,12 @@ from kivy.uix.filechooser import FileChooserListView
|
|||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
from kivy.logger import Logger
|
||||||
|
|
||||||
from kivy.properties import ObjectProperty, StringProperty, BooleanProperty, \
|
from kivy.properties import ObjectProperty, StringProperty, BooleanProperty, \
|
||||||
NumericProperty, DictProperty, OptionProperty
|
NumericProperty, DictProperty, OptionProperty
|
||||||
from pythonosc import dispatcher, osc_server
|
from pythonosc import dispatcher, osc_server
|
||||||
|
from ffpyplayer.tools import set_log_callback
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .baseWidget import PressableImage
|
from .baseWidget import PressableImage
|
||||||
|
|
||||||
@ -26,12 +29,18 @@ desktopOSs=[
|
|||||||
"macosx"
|
"macosx"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
||||||
|
'fatal': Logger.critical, 'error': Logger.error,
|
||||||
|
'warning': Logger.warning, 'info': Logger.info,
|
||||||
|
'verbose': Logger.debug, 'debug': Logger.debug}
|
||||||
|
|
||||||
othersplatforms=['ios','android']
|
othersplatforms=['ios','android']
|
||||||
|
|
||||||
class BaseVPlayer(FloatLayout):
|
class BaseVPlayer(FloatLayout):
|
||||||
fullscreen = BooleanProperty(False)
|
fullscreen = BooleanProperty(False)
|
||||||
def __init__(self,vfile=None):
|
def __init__(self,vfile=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.register_event_type('on_source_error')
|
||||||
Window.allow_screensaver = False
|
Window.allow_screensaver = False
|
||||||
self._video = Video(allow_stretch=True,pos_hint={'x': 0, 'y': 0},size_hint=(1,1))
|
self._video = Video(allow_stretch=True,pos_hint={'x': 0, 'y': 0},size_hint=(1,1))
|
||||||
self.add_widget(self._video)
|
self.add_widget(self._video)
|
||||||
@ -44,7 +53,18 @@ class BaseVPlayer(FloatLayout):
|
|||||||
self.play()
|
self.play()
|
||||||
self._video.bind(eos=self.video_end)
|
self._video.bind(eos=self.video_end)
|
||||||
self._video.bind(state=self.on_state)
|
self._video.bind(state=self.on_state)
|
||||||
|
set_log_callback(self.ffplayerLog)
|
||||||
|
|
||||||
|
def on_source_error(self,o,v):
|
||||||
|
Logger.info('safecorner: {} error'.format(v))
|
||||||
|
|
||||||
|
def ffplayerLog(self, msg, level):
|
||||||
|
msg = msg.strip()
|
||||||
|
if msg:
|
||||||
|
logger_func[level]('yffpyplayer: {}'.format(msg))
|
||||||
|
if level == 'error' and self._video.source in msg:
|
||||||
|
self.dispatch('on_source_error',self,self._video.source)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self._video is None:
|
if self._video is None:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user