简体   繁体   中英

Kivy how can I customize video's size and position

So I'm able to use the video library to play video on my GUI, but I realized the video was always placed at the middle with the default size, as there are no attribute like pos or size in video class . I would like to know if there are any way I can size and place the video like other widgets/buttons/labels.

The following example illustrates sizing and placing a video.

Example

In the following demo, we are using AnchorLayout . You can replace it with any Layouts ( BoxLyout , FloatLayout , etc.), Widget , etc. and use pos or pos_hint .

main.py

from kivy.base import runTouchApp
from kivy.lang import Builder

runTouchApp(Builder.load_string("""
AnchorLayout:
    anchor_x: 'center'
    anchor_y: 'top'
    Video:
        source: 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov'
        state: 'play'
        keep_ratio: True
        allow_stretch: True
        size_hint: 0.8, 0.8
"""))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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