bugfix
This commit is contained in:
parent
77d505af2d
commit
9cd8ad4099
@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
|
from ffpyplayer.player import MediaPlayer
|
||||||
|
from threading import Thread
|
||||||
from kivy.core.video.video_ffpyplayer import VideoFFPy
|
from kivy.core.video.video_ffpyplayer import VideoFFPy
|
||||||
|
|
||||||
def set_headers_pattern(self, pattern, headers_str):
|
headers_pattern = {
|
||||||
if not hasattr(self, 'headers_pattern'):
|
}
|
||||||
self.headers_pattern = {}
|
|
||||||
self.headers_pattern[pattern] = headers_str
|
|
||||||
|
|
||||||
def get_spec_headers(self, filename):
|
def set_headers_pattern(pattern, headers_str):
|
||||||
if not hasattr(self, 'headers_pattern'):
|
headers_pattern[pattern] = headers_str
|
||||||
return None
|
|
||||||
for p in self.headers_pattern.keys:
|
def get_spec_headers(filename):
|
||||||
|
for p in headers_pattern.keys():
|
||||||
if p in filename:
|
if p in filename:
|
||||||
return self.headers_pattern[p]
|
return headers_pattern[p]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def hack_play(self):
|
def hack_play(self):
|
||||||
@ -30,7 +31,7 @@ def hack_play(self):
|
|||||||
}
|
}
|
||||||
if self._filename.startswith('http://') or \
|
if self._filename.startswith('http://') or \
|
||||||
self._filename.startswith('https://'):
|
self._filename.startswith('https://'):
|
||||||
headers = self.get_spec_headers(self._filename)
|
headers = get_spec_headers(self._filename)
|
||||||
if headers is not None:
|
if headers is not None:
|
||||||
ff_opts['headers'] = headers
|
ff_opts['headers'] = headers
|
||||||
print('****************')
|
print('****************')
|
||||||
@ -49,6 +50,4 @@ def hack_play(self):
|
|||||||
self._thread.daemon = True
|
self._thread.daemon = True
|
||||||
self._thread.start()
|
self._thread.start()
|
||||||
|
|
||||||
setattr(VideoFFPy, 'set_headers_pattern', set_headers_pattern)
|
|
||||||
setattr(VideoFFPy, 'get_spec_headers', get_spec_headers)
|
|
||||||
setattr(VideoFFPy, 'play', hack_play)
|
setattr(VideoFFPy, 'play', hack_play)
|
||||||
|
@ -3,12 +3,12 @@ from kivy.uix.video import Video
|
|||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
from kivy.properties import BooleanProperty
|
from kivy.properties import BooleanProperty, DictProperty
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
|
||||||
from ffpyplayer.tools import set_log_callback
|
from ffpyplayer.tools import set_log_callback
|
||||||
|
|
||||||
from hack_ffpyplayer import *
|
from .hack_ffpyplayer import set_headers_pattern
|
||||||
logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
||||||
'fatal': Logger.critical, 'error': Logger.error,
|
'fatal': Logger.critical, 'error': Logger.error,
|
||||||
'warning': Logger.warning, 'info': Logger.info,
|
'warning': Logger.warning, 'info': Logger.info,
|
||||||
@ -17,6 +17,7 @@ logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
|||||||
|
|
||||||
class NewVideo(Video):
|
class NewVideo(Video):
|
||||||
center_screen = BooleanProperty(False)
|
center_screen = BooleanProperty(False)
|
||||||
|
h_pattern = DictProperty(None)
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
Video.__init__(self, **kw)
|
Video.__init__(self, **kw)
|
||||||
Window.allow_screensaver = False
|
Window.allow_screensaver = False
|
||||||
@ -29,11 +30,11 @@ class NewVideo(Video):
|
|||||||
self.bind(loaded=self.on_video_loaded)
|
self.bind(loaded=self.on_video_loaded)
|
||||||
self.load_status = None
|
self.load_status = None
|
||||||
Clock.schedule_interval(self.check_focus,0.2)
|
Clock.schedule_interval(self.check_focus,0.2)
|
||||||
|
if self.h_pattern:
|
||||||
|
[ set_headers_pattern(k,v) for k,v in self.h_pattern.items() ]
|
||||||
|
|
||||||
def set_patternheaders(self, pattern, headers_str):
|
def set_patternheaders(self, pattern, headers_str):
|
||||||
if not hasattr(self, '_video'):
|
set_headers_pattern(pattern, headers_str)
|
||||||
return
|
|
||||||
self._video.set_headers_pattern(pattern, headers_str)
|
|
||||||
|
|
||||||
def on_enter_focus(self, v=None):
|
def on_enter_focus(self, v=None):
|
||||||
pass
|
pass
|
||||||
|
@ -84,8 +84,7 @@ class WidgetCSS(object):
|
|||||||
self.width = self.width_nm
|
self.width = self.width_nm
|
||||||
|
|
||||||
def on_csscls(self, o, csscls):
|
def on_csscls(self, o, csscls):
|
||||||
if isinstance(self.csscls, str):
|
self.set_css(self.csscls)
|
||||||
self.set_css(self.csscls)
|
|
||||||
|
|
||||||
def set_css(self, css_str):
|
def set_css(self, css_str):
|
||||||
css = {}
|
css = {}
|
||||||
@ -95,13 +94,13 @@ class WidgetCSS(object):
|
|||||||
setattr(self,k,v)
|
setattr(self,k,v)
|
||||||
|
|
||||||
def on_height_c(self, o, c):
|
def on_height_c(self, o, c):
|
||||||
if not height_c:
|
if not self.height_c:
|
||||||
return
|
return
|
||||||
self.size_hint_y = None
|
self.size_hint_y = None
|
||||||
self.height = CSize(self.height_c)
|
self.height = CSize(self.height_c)
|
||||||
|
|
||||||
def on_width_c(self, o, c):
|
def on_width_c(self, o, c):
|
||||||
if not width_c:
|
if not self.width_c:
|
||||||
return
|
return
|
||||||
self.size_hint_x = None
|
self.size_hint_x = None
|
||||||
self.width = CSize(self.width_c)
|
self.width = CSize(self.width_c)
|
||||||
|
Loading…
Reference in New Issue
Block a user