簡體   English   中英

kivy VideoPlayer:全屏模式后視頻沒有恢復到原來的大小

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

當我雙擊視頻時,它會全屏顯示,但如果我再次雙擊它,它不會恢復正常。 但是,其余的窗口元素是部分可見的。 下面給出了我負責 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 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'

我進入全屏模式之前和之后的程序截圖:之前之后

通過將 VideoPlayer 小部件添加到 GridLayout 解決了此問題。 現在 .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}

不知道這是否是一個好的決定,但它有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM