Python Forum
[Kivy] video plays in the background only
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] video plays in the background only
#4
Are you trying to do something like this?



test.py
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.videoplayer import VideoPlayer


# define the Screens
class Window1(Screen):
    pass

class Window2(Screen):
    pass

class Window3(Screen):
    pass

class PlayVideo(Screen):
    pass

class MyWidget(Screen):
    pass


class WindowManager(ScreenManager):
    pass


kv = Builder.load_file('my.kv')

class MyApp(App):
    def build(self):
        return kv

MyApp().run()
my.kv
Output:
WindowManager: Window1: Window2: Window3: PlayVideo: MyWidget: <PlayVideo>: name: 'video_window' BoxLayout: orientation: 'vertical' spacing: 50 VideoPlayer: source: './videos/my.mp4' state: 'stop' size_hint_y: None height: root.height - 125 GridLayout: cols: 3 row_force_default: True row_default_height: 40 col_force_default: True col_default_width: 100 spacing: 10 padding: 10 Button: text: 'Goto 1' font_size: 20 on_release: app.root.current = 'window1' root.manager.transition.direction = 'up' Button: text: 'Goto 2' font_size: 20 on_release: app.root.current = 'window2' root.manager.transition.direction = 'up' Button: text: 'Goto 3' font_size: 20 on_release: app.root.current = 'window3' root.manager.transition.direction = 'up' <Window1>: name: 'window1' canvas.before: Color: rgba: (180/255, 50/255, 30/255, 1) Rectangle: pos: self.pos size: self.size BoxLayout: orientation: 'vertical' spacing: 50 Label: text: 'Window 1' font_size: 32 size_hint_y: None height: root.height - 125 GridLayout: cols: 3 row_force_default: True row_default_height: 40 col_force_default: True col_default_width: 100 spacing: 10 padding: 10 Button: text: 'Goto 2' font_size: 20 on_release: app.root.current = 'window2' root.manager.transition.direction = 'left' Button: text: 'Goto 3' font_size: 20 on_release: app.root.current = 'window3' root.manager.transition.direction = 'left' Button: text: 'Play Video' font_size: 20 on_release: app.root.current = 'video_window' root.manager.transition.direction = 'down' <Window2>: name: 'window2' canvas.before: Color: rgba: (10/255, 150/255, 330/255, 1) Rectangle: pos: self.pos size: self.size BoxLayout: orientation: 'vertical' size: root.width, root.height Label: text: 'Window 2' font_size: 32 size_hint_y: None height: root.height - 125 GridLayout: cols: 3 row_force_default: True row_default_height: 40 col_force_default: True col_default_width: 100 spacing: 10 padding: 10 Button: text: 'Goto 1' font_size: 20 on_release: app.root.current = 'window1' root.manager.transition.direction = 'right' Button: text: 'Goto 3' font_size: 20 on_release: app.root.current = 'window3' root.manager.transition.direction = 'left' Button: text: 'Play Video' font_size: 20 on_release: app.root.current = 'video_window' root.manager.transition.direction = 'down' <Window3> name: 'window3' canvas.before: Color: rgba: (10/255, 90/255, 30/255, 1) Rectangle: pos: self.pos size: self.size BoxLayout: orientation: 'vertical' size: root.width, root.height Label: text: 'Window 3' font_size: 32 size_hint_y: None height: root.height - 125 GridLayout: cols: 3 row_force_default: True row_default_height: 40 col_force_default: True col_default_width: 100 spacing: 10 padding: 10 Button: text: 'Goto 1' font_size: 20 on_release: app.root.current = 'window1' root.manager.transition.direction = 'right' Button: text: 'Goto 2' font_size: 20 on_release: app.root.current = 'window2' root.manager.transition.direction = 'right' Button: text: 'Play Video' font_size: 20 on_release: app.root.current = 'video_window' root.manager.transition.direction = 'down'
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
video plays in the background only - by Gorashy - Jun-17-2024, 06:32 PM
RE: video plays in the background only - by Gorashy - Jun-17-2024, 08:02 PM
RE: video plays in the background only - by Gorashy - Jun-18-2024, 04:37 AM
RE: video plays in the background only - by menator01 - Jun-19-2024, 02:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Button Plays Random .MP3 File From Folder blufacebaby 2 2,251 Feb-05-2021, 02:19 AM
Last Post: BashBedlam
  [PyQt] Embedding a Video in Video Player WhatsupSmiley 0 6,097 Jan-28-2019, 06:24 PM
Last Post: WhatsupSmiley
  set button background with image of window background gray 3 14,662 Oct-18-2017, 08:22 AM
Last Post: gray

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020