我正在使用python-vlc
库(版本3.0.16129)为树莓派编写视频播放器。我看到一个奇怪的问题,即玩家并不总是以全屏打开,也许10次中有1次视频以窗口模式开始,10次中有9次运行良好。有人看到/解决了这个问题吗?
class VideoPlayer:
def __init__(self):
os.environ["VLC_VERBOSE"] = "-1"
self._instance: Instance = Instance(["--video-on-top"])
self._player: MediaPlayer = self._instance.media_player_new()
def play(video_path: str):
self._player.set_fullscreen(True)
self._player.stop() # often need to supersede videos already playing
self._player.set_media(video_path)
self._player.play()
set_fullscreen
和toggle_fullscreen
函数都有一个警告:
def toggle_fullscreen(self):
'''Toggle fullscreen status on non-embedded video outputs.
@warning: The same limitations applies to this function
as to L{set_fullscreen}().
'''
return libvlc_toggle_fullscreen(self)
def set_fullscreen(self, b_fullscreen):
'''Enable or disable fullscreen.
@warning: With most window managers, only a top-level windows can be in
full-screen mode. Hence, this function will not operate properly if
L{set_xwindow}() was used to embed the video in a
non-top-level window. In that case, the embedding window must be reparented
to the root window B{before} fullscreen mode is enabled. You will want
to reparent it back to its normal parent when disabling fullscreen.
@param b_fullscreen: boolean for fullscreen status.
'''
return libvlc_set_fullscreen(self, b_fullscreen)
在不知道你的视频播放器是如何实现的情况下,也许它与此有关。