bugfix
This commit is contained in:
parent
b07b37b22b
commit
77d505af2d
54
kivyblocks/hack_ffpyplayer.py
Normal file
54
kivyblocks/hack_ffpyplayer.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
from kivy.core.video.video_ffpyplayer import VideoFFPy
|
||||||
|
|
||||||
|
def set_headers_pattern(self, pattern, headers_str):
|
||||||
|
if not hasattr(self, 'headers_pattern'):
|
||||||
|
self.headers_pattern = {}
|
||||||
|
self.headers_pattern[pattern] = headers_str
|
||||||
|
|
||||||
|
def get_spec_headers(self, filename):
|
||||||
|
if not hasattr(self, 'headers_pattern'):
|
||||||
|
return None
|
||||||
|
for p in self.headers_pattern.keys:
|
||||||
|
if p in filename:
|
||||||
|
return self.headers_pattern[p]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def hack_play(self):
|
||||||
|
if self._ffplayer and self._state == 'paused':
|
||||||
|
self._ffplayer.toggle_pause()
|
||||||
|
self._state = 'playing'
|
||||||
|
return
|
||||||
|
|
||||||
|
self.load()
|
||||||
|
self._out_fmt = 'rgba'
|
||||||
|
ff_opts = {
|
||||||
|
'paused': True,
|
||||||
|
'out_fmt': self._out_fmt,
|
||||||
|
'sn': True,
|
||||||
|
'volume': self._volume,
|
||||||
|
}
|
||||||
|
if self._filename.startswith('http://') or \
|
||||||
|
self._filename.startswith('https://'):
|
||||||
|
headers = self.get_spec_headers(self._filename)
|
||||||
|
if headers is not None:
|
||||||
|
ff_opts['headers'] = headers
|
||||||
|
print('****************')
|
||||||
|
print('*VideoFFPy():ff_opts=', ff_opts)
|
||||||
|
print('****************')
|
||||||
|
|
||||||
|
self._ffplayer = MediaPlayer(
|
||||||
|
self._filename, callback=self._player_callback,
|
||||||
|
thread_lib='SDL',
|
||||||
|
loglevel='info', ff_opts=ff_opts)
|
||||||
|
|
||||||
|
# Disabled as an attempt to fix kivy issue #6210
|
||||||
|
# self._ffplayer.set_volume(self._volume)
|
||||||
|
|
||||||
|
self._thread = Thread(target=self._next_frame_run, name='Next frame')
|
||||||
|
self._thread.daemon = True
|
||||||
|
self._thread.start()
|
||||||
|
|
||||||
|
setattr(VideoFFPy, 'set_headers_pattern', set_headers_pattern)
|
||||||
|
setattr(VideoFFPy, 'get_spec_headers', get_spec_headers)
|
||||||
|
setattr(VideoFFPy, 'play', hack_play)
|
@ -8,6 +8,7 @@ from kivy.clock import Clock
|
|||||||
|
|
||||||
from ffpyplayer.tools import set_log_callback
|
from ffpyplayer.tools import set_log_callback
|
||||||
|
|
||||||
|
from hack_ffpyplayer import *
|
||||||
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,
|
||||||
@ -29,6 +30,11 @@ class NewVideo(Video):
|
|||||||
self.load_status = None
|
self.load_status = None
|
||||||
Clock.schedule_interval(self.check_focus,0.2)
|
Clock.schedule_interval(self.check_focus,0.2)
|
||||||
|
|
||||||
|
def set_patternheaders(self, pattern, headers_str):
|
||||||
|
if not hasattr(self, '_video'):
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user