GithubHelp home page GithubHelp logo

Comments (4)

FeodorFitsner avatar FeodorFitsner commented on May 24, 2024

Adding a small delay makes second example work:

import time
import flet as ft


def main(page: ft.Page):
    sample_media = [
        ft.VideoMedia("https://user-images.githubusercontent.com/28951144/229373720-14d69157-1a56-4a78-a2f4-d7a134d7c3e9.mp4")
    ]

    page.theme_mode = ft.ThemeMode.DARK
    page.title = "Test app"
    page.padding = 0
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.add(
        video := ft.Video(
            expand=True,
            playlist=sample_media,
            playlist_mode=ft.PlaylistMode.SINGLE,
            fill_color=ft.colors.BACKGROUND,
            aspect_ratio=16 / 9,
            volume=100,
            autoplay=True,
            filter_quality=ft.FilterQuality.LOW,
            muted=False,
            wakelock=True,
            show_controls=False,
        )
    )
    time.sleep(2)
    print(video.is_playing())


ft.app(target=main)

This could be explained by video is not rendered/initialized when we call video.is_playing().
We need to figure out how to chain/synchronize that.

from flet.

FeodorFitsner avatar FeodorFitsner commented on May 24, 2024

Ideally, you should call is_playing() in on_loaded event handler.
Imagine, that video is being loaded in 10 seconds or longer. page.add method is not synchronous anyway, but you are trying to poll if it's playing right away.

Btw, it's not working when calling inside on_loaded too. Will be looking into that issue - looks like a bug.

from flet.

syleishere avatar syleishere commented on May 24, 2024

Could use add the track stream to video? Currently no way to know which video is playing...

from flet.

bl1nch avatar bl1nch commented on May 24, 2024

Could use add the track stream to video? Currently no way to know which video is playing...

Perhaps a good way to track this is to add an on_media_changed event with the media source parameter and its index in the playlist. It might also be useful to implement events such as on_player_start and on_player_completed.

from flet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.