This commit is contained in:
yumoqing 2022-04-06 14:00:57 +08:00
parent 2ff7c0469e
commit c9762275b6

View File

@ -1,4 +1,5 @@
from functools import partial
from ffpyplayer.player import MediaPlayer from ffpyplayer.player import MediaPlayer
from threading import Thread from threading import Thread
from kivy.core.video.video_ffpyplayer import VideoFFPy from kivy.core.video.video_ffpyplayer import VideoFFPy
@ -15,42 +16,15 @@ def get_spec_headers(filename):
return headers_pattern[p] return headers_pattern[p]
return None return None
def hack_play(self): old_init = getattr(MediaPlayer, '__init__')
print('****************')
print('****************')
print('hack_play() called ...')
if self._ffplayer and self._state == 'paused':
self._ffplayer.toggle_pause()
self._state = 'playing'
return
self.load() def mediaplayer_init(self, filename, *args, lib_opts={}, **kw):
self._out_fmt = 'rgba' print('******************** MediaPlayer __init__ hacked *****')
ff_opts = {
'paused': True,
'out_fmt': self._out_fmt,
'sn': True,
'volume': self._volume,
}
if self._filename.startswith('http://') or \ if self._filename.startswith('http://') or \
self._filename.startswith('https://'): self._filename.startswith('https://'):
headers = get_spec_headers(self._filename) headers = get_spec_headers(self._filename)
if headers is not None: if headers is not None:
ff_opts['headers'] = "$'%s'" % headers lib_opts['headers'] = "$'%s'" % headers
print('****************') old_init(self, file, *args, lib_opts=lib_opts, **kw)
print('*VideoFFPy():ff_opts=', ff_opts)
print('****************')
self._ffplayer = MediaPlayer( # setattr(MediaPlayer, '__init__', mediaplayer_init)
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, 'play', hack_play)