简体   繁体   English

kivy VideoPlayer:全屏模式后视频没有恢复到原来的大小

[英]kivy VideoPlayer: Video does not return to its original size after full screen mode

When I double click on the video, it goes full screen, but if I double click on it again, it doesn't go back to normal.当我双击视频时,它会全屏显示,但如果我再次双击它,它不会恢复正常。 However, the rest of the window elements are partially visible.但是,其余的窗口元素是部分可见的。 The part of my .kv code responsible for the VideoPlayer is given below:下面给出了我负责 VideoPlayer 的 .kv 代码部分:

<VideosWindow>:
name: 'vids'
FloatLayout:
    FileChooserListView:
        id:chooser
        path: root.get_files_list() 
        canvas.before:
            Color:
                rgb: .4, .5, .5
            Rectangle:
                pos: self.pos
                size: self.size
                on_selection: root.select(chooser.selection)
        size_hint: (.9, .15)
        pos_hint: {'x':.05, 'y':.8} 
    VideoPlayer:
        id:vid
        options: {'eos':'loop'}
        size_hint: (.9, .7)
        pos_hint: {'x':.05, 'y':.05} 
    Button:
        size_hint_y: 0.3
        height: 48
        text: "open"
        disabled: not chooser.selection  
        on_release: root.select(chooser.selection)
        size_hint: (.45, .05)
        pos_hint: {'x':.05, 'y':.00}
    Button:
        text: 'Go Back'
        color: (1,1,1,1)
        background_normal:''
        background_color: (0.3,0.6,0.7,1)
        on_release: 
            vid.state = 'pause'
            app.root.current = 'saved_files'
        size_hint: (.45, .05)
        pos_hint: {'x':.50, 'y':.00}

VideosWindow class code: VideosWindow 类代码:

class VideosWindow(Screen):
def get_files_list(self):
    files = os.sep.join([my_folder,'mp4'])
    return files

def select(self, filename):
    self.ids.vid.source = filename[0]
    self.ids.vid.state = 'play'

The screenshots of my program before and after I go fullscreen mode: before after我进入全屏模式之前和之后的程序截图:之前之后

Solved this issue by adding VideoPlayer widget to the GridLayout.通过将 VideoPlayer 小部件添加到 GridLayout 解决了此问题。 Now .kv code looks like this:现在 .kv 代码如下所示:

<VideosWindow>:
name: 'vids'
FloatLayout:
    FileChooserListView:
        id:chooser
        path: root.get_files_list() 
        canvas.before:
            Color:
                rgb: .4, .5, .5
            Rectangle:
                pos: self.pos
                size: self.size
                on_selection: root.select(chooser.selection)
        size_hint: (.9, .15)
        pos_hint: {'x':.05, 'y':.8} 


    GridLayout:
        cols:1
        size_hint: (.9, .7)
        pos_hint: {'x':.05, 'y':.05} 
        VideoPlayer:
            id:vid
            options: {'eos':'loop'}      

      
    Button:
        size_hint_y: 0.3
        height: 48
        text: "open"
        disabled: not chooser.selection  
        on_release: root.select(chooser.selection)
        size_hint: (.45, .05)
        pos_hint: {'x':.05, 'y':.00}
    Button:
        text: 'Go Back'
        color: (1,1,1,1)
        background_normal:''
        background_color: (0.3,0.6,0.7,1)
        on_release: 
            vid.state = 'pause'
            app.root.current = 'saved_files'
        size_hint: (.45, .05)
        pos_hint: {'x':.50, 'y':.00}

Don't know if it is good decision but it works.不知道这是否是一个好的决定,但它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM