bugfix
This commit is contained in:
parent
a77b01d230
commit
efcd7785b9
@ -23,7 +23,6 @@ from kivy.app import App
|
|||||||
from .threadcall import HttpClient,Workers
|
from .threadcall import HttpClient,Workers
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .pagescontainer import PageContainer
|
from .pagescontainer import PageContainer
|
||||||
from .widgetExt.messager import Messager
|
|
||||||
from .blocks import Blocks
|
from .blocks import Blocks
|
||||||
from .theming import ThemeManager
|
from .theming import ThemeManager
|
||||||
from appPublic.rsa import RSA
|
from appPublic.rsa import RSA
|
||||||
|
@ -134,7 +134,7 @@ class InputBox(BoxLayout):
|
|||||||
"otext":label,
|
"otext":label,
|
||||||
"font_size":CSize(1),
|
"font_size":CSize(1),
|
||||||
"size_hint_y":None,
|
"size_hint_y":None,
|
||||||
"height":CSize(2)
|
"height":CSize(3)
|
||||||
}
|
}
|
||||||
if self.labelwidth<=1:
|
if self.labelwidth<=1:
|
||||||
kwargs['size_hint_x'] = self.labelwidth
|
kwargs['size_hint_x'] = self.labelwidth
|
||||||
@ -147,6 +147,8 @@ class InputBox(BoxLayout):
|
|||||||
options = self.uidef.get('options',{}).copy()
|
options = self.uidef.get('options',{}).copy()
|
||||||
options.update(self.options.get('uiparams',{}))
|
options.update(self.options.get('uiparams',{}))
|
||||||
options['allow_copy'] = True
|
options['allow_copy'] = True
|
||||||
|
options['size_hint_y'] = None
|
||||||
|
options['height'] = CSize(3)
|
||||||
if self.options.get('tip'):
|
if self.options.get('tip'):
|
||||||
options['hint_text'] = i18n(self.options.get('tip'))
|
options['hint_text'] = i18n(self.options.get('tip'))
|
||||||
|
|
||||||
@ -269,6 +271,7 @@ class StrSearchForm(BoxLayout):
|
|||||||
self.inputwidget = TextInput(
|
self.inputwidget = TextInput(
|
||||||
text='',
|
text='',
|
||||||
multiline=False,
|
multiline=False,
|
||||||
|
allow_copy=True,
|
||||||
font_size=CSize(1),
|
font_size=CSize(1),
|
||||||
size_hint_y=None,
|
size_hint_y=None,
|
||||||
height=CSize(3))
|
height=CSize(3))
|
||||||
|
@ -56,7 +56,8 @@ class LoginForm(Popup):
|
|||||||
if userinfo.get('passwd',False):
|
if userinfo.get('passwd',False):
|
||||||
userinfo['authmethod'] = 'password'
|
userinfo['authmethod'] = 'password'
|
||||||
authinfo = app.serverinfo.encode(userinfo)
|
authinfo = app.serverinfo.encode(userinfo)
|
||||||
login_url = '%s%s' % (app.config.uihome, app.config.login_url)
|
config = getConfig()
|
||||||
|
login_url = '%s%s' % (config.uihome, config.login_url)
|
||||||
x = app.hc.get(login_url)
|
x = app.hc.get(login_url)
|
||||||
print('login return=', x, login_url, authinfo)
|
print('login return=', x, login_url, authinfo)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import traceback
|
import traceback
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
from kivy.logger import Logger
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.uix.button import Button
|
from kivy.uix.button import Button
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
@ -30,16 +31,19 @@ class PagingButton(Button):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
class HttpLoader:
|
class HttpLoader:
|
||||||
def __init__(self, url, method, params):
|
def __init__(self, url, method, params,page_rows=60):
|
||||||
self.page_rows = page_rows
|
self.page_rows = page_rows
|
||||||
self.url = url
|
self.url = url
|
||||||
self.method = method,
|
self.method = method
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
def setParams(self,params):
|
def setParams(self,params, url=None, page_rows=60):
|
||||||
self.params = params
|
self.params = params
|
||||||
|
if url is not None:
|
||||||
|
self.url = url
|
||||||
|
self.page_rows = page_rows
|
||||||
|
|
||||||
def load(self, callback, errback):
|
def load(self, callback, errback=None):
|
||||||
hc = App.get_running_app().hc
|
hc = App.get_running_app().hc
|
||||||
x = hc(self.url,
|
x = hc(self.url,
|
||||||
method=self.method,
|
method=self.method,
|
||||||
@ -58,16 +62,18 @@ class PageLoader:
|
|||||||
self.params = options.get('params',{})
|
self.params = options.get('params',{})
|
||||||
self.method = options.get('method','GET')
|
self.method = options.get('method','GET')
|
||||||
self.url = options.get('dataurl')
|
self.url = options.get('dataurl')
|
||||||
|
self.page_rows = options.get('page_rows',60)
|
||||||
self.total_cnt = 0
|
self.total_cnt = 0
|
||||||
self.total_page = 0
|
self.total_page = 0
|
||||||
self.page_rows = options.get('page_rows',0)
|
|
||||||
self.curpage = 0
|
self.curpage = 0
|
||||||
|
Logger.info('kivyblocks: method=%s,type=%s',str(self.method),type(self.method))
|
||||||
|
self.loader = HttpLoader(self.url, self.method, self.params )
|
||||||
|
|
||||||
def do_search(self,o,params):
|
def do_search(self,o,params):
|
||||||
print('PageLoader().do_search(), on_submit handle....',params)
|
print('PageLoader().do_search(), on_submit handle....',params)
|
||||||
self.clearer()
|
self.clearer()
|
||||||
self.params.update(params)
|
self.params.update(params)
|
||||||
print('do_search():,params=',self.params)
|
self.loader.setParams(self.params)
|
||||||
self.loadPage(1)
|
self.loadPage(1)
|
||||||
|
|
||||||
def calculateTotalPage(self):
|
def calculateTotalPage(self):
|
||||||
@ -104,6 +110,10 @@ class PageLoader:
|
|||||||
r['__posInSet__'] = p
|
r['__posInSet__'] = p
|
||||||
p += 1
|
p += 1
|
||||||
|
|
||||||
|
def httperror(self,o,e):
|
||||||
|
traceback.print_exc()
|
||||||
|
alert(str(e),title='alert')
|
||||||
|
|
||||||
def loadPage(self,p):
|
def loadPage(self,p):
|
||||||
if not self.url:
|
if not self.url:
|
||||||
raise Exception('dataurl must be present:options=%s' % str(options))
|
raise Exception('dataurl must be present:options=%s' % str(options))
|
||||||
@ -114,16 +124,9 @@ class PageLoader:
|
|||||||
"page":self.curpage,
|
"page":self.curpage,
|
||||||
"rows":self.page_rows
|
"rows":self.page_rows
|
||||||
})
|
})
|
||||||
hc = App.get_running_app().hc
|
|
||||||
url = absurl(self.url,self.target.parenturl)
|
url = absurl(self.url,self.target.parenturl)
|
||||||
# print('loadPage():url=',url,'params=',params)
|
self.loader.setParams(params,url=url)
|
||||||
x = hc(url,method=self.method,
|
self.loader.load(self.show_page,self.httperror)
|
||||||
params=params,callback=self.show_page,
|
|
||||||
errback=self.httperror)
|
|
||||||
|
|
||||||
def httperror(self,o,e):
|
|
||||||
traceback.print_exc()
|
|
||||||
alert(str(e),title='alert')
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ from kivy.properties import ObjectProperty, StringProperty, BooleanProperty, \
|
|||||||
from pythonosc import dispatcher, osc_server
|
from pythonosc import dispatcher, osc_server
|
||||||
from ffpyplayer.tools import set_log_callback
|
from ffpyplayer.tools import set_log_callback
|
||||||
from .utils import *
|
from .utils import *
|
||||||
|
from .paging import PageLoader
|
||||||
from .baseWidget import PressableImage
|
from .baseWidget import PressableImage
|
||||||
|
|
||||||
desktopOSs=[
|
desktopOSs=[
|
||||||
@ -36,22 +37,33 @@ logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
|||||||
|
|
||||||
othersplatforms=['ios','android']
|
othersplatforms=['ios','android']
|
||||||
|
|
||||||
|
class UrlPlayList(PageLoader):
|
||||||
|
def __init__(self, player, **options):
|
||||||
|
self.player = player
|
||||||
|
PageLoader.__init__(self,**options)
|
||||||
|
|
||||||
|
def show_page(self,o,d):
|
||||||
|
super().show_page(o,d)
|
||||||
|
id = d['rows'][0].id
|
||||||
|
self.player.play(id)
|
||||||
|
|
||||||
class BaseVPlayer(FloatLayout):
|
class BaseVPlayer(FloatLayout):
|
||||||
fullscreen = BooleanProperty(False)
|
fullscreen = BooleanProperty(False)
|
||||||
def __init__(self,vfile=None):
|
def __init__(self,vfile=None,playlist=[]):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.register_event_type('on_source_error')
|
self.register_event_type('on_source_error')
|
||||||
|
self.register_event_type('on_next')
|
||||||
|
self.register_event_type('on_previous')
|
||||||
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)
|
||||||
self.ffplayer = None
|
|
||||||
if type(vfile) == type([]):
|
if type(vfile) == type([]):
|
||||||
self.playlist = vfile
|
self.playlist = vfile
|
||||||
else:
|
else:
|
||||||
self.playlist = [vfile]
|
self.playlist = [vfile]
|
||||||
self.curplay = 0
|
self.curplay = 0
|
||||||
self.old_volume = 0
|
self.old_volume = 0
|
||||||
self._video.bind(eos=self.video_end)
|
self._video.bind(eos=self.next)
|
||||||
self._video.bind(state=self.on_state)
|
self._video.bind(state=self.on_state)
|
||||||
set_log_callback(self.ffplayerLog)
|
set_log_callback(self.ffplayerLog)
|
||||||
self.play()
|
self.play()
|
||||||
@ -61,6 +73,11 @@ class BaseVPlayer(FloatLayout):
|
|||||||
def on_source_error(self,o,v):
|
def on_source_error(self,o,v):
|
||||||
Logger.info('safecorner: {} error'.format(v))
|
Logger.info('safecorner: {} error'.format(v))
|
||||||
|
|
||||||
|
def on_next(self,o=None, v=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_previous(self, o=None, v=None):
|
||||||
|
pass
|
||||||
def ffplayerLog(self, msg, level):
|
def ffplayerLog(self, msg, level):
|
||||||
msg = msg.strip()
|
msg = msg.strip()
|
||||||
if msg:
|
if msg:
|
||||||
@ -73,23 +90,17 @@ class BaseVPlayer(FloatLayout):
|
|||||||
self._video.source = self.playlist[self.curplay]
|
self._video.source = self.playlist[self.curplay]
|
||||||
self._video.state = 'play'
|
self._video.state = 'play'
|
||||||
|
|
||||||
def on_playend(self,o=None,v=None):
|
def next(self,o=None,v=None):
|
||||||
pass
|
self.dispatch('on_next',self)
|
||||||
|
|
||||||
def addPlaylist(self,lst):
|
def previous(self,o=None,v=None):
|
||||||
self.playlist += lst
|
self.dispatch('on_previous',self)
|
||||||
|
|
||||||
def video_end(self,t,v):
|
def on_state(self,o=None,v=None):
|
||||||
pass
|
|
||||||
|
|
||||||
def on_state(self,o,v):
|
|
||||||
if self._video.state == 'play':
|
if self._video.state == 'play':
|
||||||
Window.allow_screensaver = False
|
Window.allow_screensaver = False
|
||||||
if hasattr(self._video._video, '_ffplayer'):
|
|
||||||
self.ffplayer = self._video._video._ffplayer
|
|
||||||
else:
|
else:
|
||||||
Window.allow_screensaver = True
|
Window.allow_screensaver = True
|
||||||
print('onstate()',o,v,self._video.state)
|
|
||||||
|
|
||||||
def on_fullscreen(self, instance, value):
|
def on_fullscreen(self, instance, value):
|
||||||
window = self.get_parent_window()
|
window = self.get_parent_window()
|
||||||
@ -150,15 +161,14 @@ class BaseVPlayer(FloatLayout):
|
|||||||
if platform in desktopOSs:
|
if platform in desktopOSs:
|
||||||
Window.restore()
|
Window.restore()
|
||||||
|
|
||||||
def endplay(self,btn):
|
def endplay(self,btn=None):
|
||||||
self._video.seek(1.0,precise=True)
|
self._video.seek(1.0,precise=True)
|
||||||
|
|
||||||
def replay(self,btn):
|
def replay(self,btn=None):
|
||||||
self._video.seek(0.0,precise=True)
|
self._video.seek(0.0,precise=True)
|
||||||
|
|
||||||
def audioswitch(self,btn):
|
def audioswitch(self,btn=None):
|
||||||
x = self._video._video._ffplayer.request_channel('audio')
|
x = self._video._video._ffplayer.request_channel('audio')
|
||||||
print('*********AUDIOSwitch 1**************',x)
|
|
||||||
|
|
||||||
def setVolume(self,obj,v):
|
def setVolume(self,obj,v):
|
||||||
self._video.volume = v
|
self._video.volume = v
|
||||||
@ -166,14 +176,12 @@ class BaseVPlayer(FloatLayout):
|
|||||||
def setPosition(self,obj,v):
|
def setPosition(self,obj,v):
|
||||||
self._video.seek(v)
|
self._video.seek(v)
|
||||||
|
|
||||||
def mute(self,btn):
|
def mute(self,btn=None):
|
||||||
if self._video.volume > 0.001:
|
if self._video.volume > 0.001:
|
||||||
self.old_volume = self._video.volume
|
self.old_volume = self._video.volume
|
||||||
self._video.volume = 0.0
|
self._video.volume = 0.0
|
||||||
print('********* set mute ***********',self._video.volume)
|
|
||||||
else:
|
else:
|
||||||
self._video.volume = self.old_volume
|
self._video.volume = self.old_volume
|
||||||
print('********* unset mute ***********',self._video.volume)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._video.state = 'stop'
|
self._video.state = 'stop'
|
||||||
@ -187,7 +195,7 @@ class BaseVPlayer(FloatLayout):
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class OSCVPlayer(BaseVPlayer):
|
class OSCController:
|
||||||
def __init__(self,ip,port,vfile=None):
|
def __init__(self,ip,port,vfile=None):
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.port = port
|
self.port = port
|
||||||
@ -199,27 +207,19 @@ class OSCVPlayer(BaseVPlayer):
|
|||||||
self.map('/atrack',self.audioswitch)
|
self.map('/atrack',self.audioswitch)
|
||||||
self.map('/endplay',self.endplay)
|
self.map('/endplay',self.endplay)
|
||||||
self.map('/replay',self.replay)
|
self.map('/replay',self.replay)
|
||||||
self.map('/setvalume',self.setVolume)
|
|
||||||
self.map('/setposition',self.setPosition)
|
|
||||||
self.map('/next',self.next)
|
self.map('/next',self.next)
|
||||||
|
self.map('/prevous',self.prevous)
|
||||||
self.server.serve_forever()
|
self.server.serve_forever()
|
||||||
self.fullscreen = True
|
self.fullscreen = True
|
||||||
label = Label(text='%s %d' % (self.ip,self.port), font_size=CSize(2))
|
label = Label(text='%s %d' % (self.ip,self.port), font_size=CSize(2))
|
||||||
label.size = self.width - label.width, 0
|
label.size = self.width - label.width, 0
|
||||||
self.add_widget(label)
|
self.add_widget(label)
|
||||||
|
|
||||||
def next(self,obj):
|
|
||||||
self.source = self.vfile + '?t=%f' % time.time()
|
|
||||||
|
|
||||||
def map(self,p,f):
|
def map(self,p,f):
|
||||||
self.dispatcher.map(p,f,None)
|
self.dispatcher.map(p,f,None)
|
||||||
|
|
||||||
class VPlayer(BaseVPlayer):
|
class VPlayer(BaseVPlayer):
|
||||||
def __init__(self,vfile=None,
|
def __init__(self,vfile=None, loop=False):
|
||||||
playlist=None,
|
|
||||||
loop=False
|
|
||||||
):
|
|
||||||
super().__init__(vfile=vfile)
|
super().__init__(vfile=vfile)
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
self.menubar = None
|
self.menubar = None
|
||||||
@ -239,17 +239,6 @@ class VPlayer(BaseVPlayer):
|
|||||||
self.playlist = []
|
self.playlist = []
|
||||||
self.curplay = -1
|
self.curplay = -1
|
||||||
self._video.bind(on_touch_down=self.show_hide_menu)
|
self._video.bind(on_touch_down=self.show_hide_menu)
|
||||||
self.register_event_type('on_playend')
|
|
||||||
|
|
||||||
def video_end(self,t,v):
|
|
||||||
self.curplay += 1
|
|
||||||
if not self.loop and self.curplay >= len(self.playlist):
|
|
||||||
self.dispatch('on_playend')
|
|
||||||
print('*****EOS return *************')
|
|
||||||
self.beforeDestroy()
|
|
||||||
return
|
|
||||||
self.curplay = self.curplay % len(self.playlist)
|
|
||||||
self._video.source = self.playlist[self.curplay]
|
|
||||||
|
|
||||||
def totime(self,dur):
|
def totime(self,dur):
|
||||||
h = dur / 3600
|
h = dur / 3600
|
||||||
@ -295,6 +284,8 @@ class VPlayer(BaseVPlayer):
|
|||||||
self.manualMode = False
|
self.manualMode = False
|
||||||
|
|
||||||
def update_slider(self,t):
|
def update_slider(self,t):
|
||||||
|
if self._video.state != 'play':
|
||||||
|
return
|
||||||
if self.pb is None:
|
if self.pb is None:
|
||||||
return
|
return
|
||||||
self.curposition.text = self.totime(self._video.position)
|
self.curposition.text = self.totime(self._video.position)
|
||||||
|
Loading…
Reference in New Issue
Block a user