如何去除视频播放前出现的白色方块?

How to remove the white square that appear before the playback of video?

目标:


预期结果:


实际结果:


main.py:

class ScreenThree(Screen):
    def __init__(self, **kwargs):
        super(ScreenThree, self).__init__(**kwargs)
        self.video1 = Video(source="somevideo.mpg")
        box_layout = BoxLayout()
        self.add_widget(box_layout)
        box_layout.add_widget(self.video1)
        self.video1.opacity = 0

    def on_enter(self):
        self.video1.allow_stretch = True
        self.video1.opacity = 1
        self.video1.state = "play"


显示白色方块的图像。


显示白色方块的全屏图像


感谢阅读!!!

我认为您可以通过稍微延迟 opacity 的设置来隐藏那个白色方块。尝试将您的 on_enter() 修改为:

def on_enter(self):
    self.video1.allow_stretch = True
    self.video1.state = "play"
    Clock.schedule_once(self.adjust_opacity, 0.1)

def adjust_opacity(self, dt):
    self.video1.opacity = 1

这会像您已经执行的那样开始播放视频,但会延迟更改不透明度 0.1 秒。这对我有用,但您可能会错过视频开头的一小部分。