Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Kivy Example

menator01

Gold Coder
My first test kivy project. It's simple. The only thing I can't seem to get to work is the video thumbnail from web. If it's in the local directory it works.
You can learn more about kivy from here.

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


# Define the Screens
class Window1(Screen):
    pass

class Window2(Screen):
    pass

class Window3(Screen):
    pass

class PlayVideo(Screen):
    pass

# Window Manager handles all screens
class WindowManager(ScreenManager):
    pass


class MyApp(App):
    def build(self):
        return Builder.load_file('test.kv')

if __name__ == '__main__':
    app = MyApp()
    app.run()

test.kv

Code:
WindowManager:
    Window1:
    Window2:
    Window3:
    PlayVideo:   

<PlayVideo>:
    name: 'video_window'

    BoxLayout:
        orientation: 'vertical'
        spacing: 50

        VideoPlayer:
            source: 'https://my-python.org/videos/my.mp4'
            state: 'stop'
            size_hint_y: None
            height: root.height - 125
            thumbnail: 'https://my-python.org/videos/my.png'
            
            

        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 think its in kivy itself. I get an error saying the mp4 file can't be found but, it does play the file. Just doesn't download the thumbnail image/overlay. The first is when I call the local image. The second is when I call from the web. As stated the mp4 file plays, just don't get the image.
 

Attachments

  • Kazam_screenshot_00000.png
    Kazam_screenshot_00000.png
    106.6 KB · Views: 3
  • Kazam_screenshot_00001.png
    Kazam_screenshot_00001.png
    18 KB · Views: 3
Last edited:
The first is when I call the local image. The second is when I call from the web. As stated the mp4 file plays, just don't get the image.
What do you mean with "call the local image"? That it works when you code it like this ?
Code:
VideoPlayer:
            thumbnail: 'c:/some_local_dir/my.png'
If that is so, why would it not work when you use an URL ? Is it actually trying to download the png file ? Have you checked the Network tab ? Do you get an error somewhere ?
 
As you can see in the image I get two errors. The first is for the png file, the second is the mp4. The mp4 file plays. I think it's in kivy module somewhere. In the docs I don't even need to add the thumbnail part if the png file is in the same folder as the mp4. I added it to test if it would get the file.
 

Attachments

  • Kazam_screenshot_00000.png
    Kazam_screenshot_00000.png
    228.9 KB · Views: 6
As you can see in the image I get two errors. The first is for the png file, the second is the mp4. The mp4 file plays. I think it's in kivy module somewhere. In the docs I don't even need to add the thumbnail part if the png file is in the same folder as the mp4. I added it to test if it would get the file.
Ok, that makes the problem a little clearer at least. I now realize my mistake in blabbing about the debugger Network tab 🙄
I guess you'd better report it to kivy support then.
I have a feeling there must be more detailed information than just "not found" which seems a peculiar thing to report for a network client. Perhaps something on the server side ?
 

New Threads

Buy us a coffee!

Back
Top Bottom