Coder Social home page Coder Social logo

iced_video_player's Introduction

Iced Video Player Widget

Composable component to play videos in any Iced application built on the excellent GStreamer library.

Overview

In general, this supports anything that gstreamer/playbin supports.

Features:

  • Load video files from any file path or URL (support for streaming over network).
  • Video buffering when streaming on a network.
  • Audio support.
  • Programmatic control.
  • Small (around 300 lines).
  • Capture thumbnails from a set of timestamps.

Limitations (hopefully to be fixed):

  • GStreamer hardware acceleration not working? (leads to choppy playback in some scenarios).
  • GStreamer is a bit annoying to set up on Windows.

This is a "composable" instead of a iced::Widget. This is because Widgets don't support subscriptions (yet?). Once Iced gets animation support (i.e. widgets scheduling a time to update), this can become a widget.

The player does not come with any surrounding GUI controls, but they should be quite easy to implement should you need them.

Example Usage

use iced_video_player::{VideoPlayerMessage, VideoPlayer};
use iced::{executor, Application, Command, Element, Subscription};

fn main() {
    App::run(Default::default());
}

#[derive(Debug)]
enum Message {
    VideoPlayerMessage(VideoPlayerMessage),
}

struct App {
    video: VideoPlayer,
}

impl Application for App {
    type Executor = executor::Default;
    type Message = Message;
    type Flags = ();

    fn new(_flags: ()) -> (Self, Command<Message>) {
        (
            App {
                video: VideoPlayer::new(&url::Url::parse("file:///C:/my_video.mp4").unwrap()).unwrap(),
            },
            Command::none(),
        )
    }

    fn title(&self) -> String {
        String::from("Video Player")
    }

    fn update(&mut self, message: Message) -> Command<Message> {
        match message {
            Message::VideoPlayerMessage(msg) => self.video.update(msg),
        }
        Command::none()
    }

    fn subscription(&self) -> Subscription<Message> {
        self.video.subscription().map(Message::VideoPlayerMessage)
    }

    fn view(&mut self) -> Element<Message> {
        self.video.frame_view().into()
    }
}

Building

Follow the GStreamer build instructions. This should be able to compile on MSVC, MinGW, Linux, and MacOS.

License

Licensed under either

at your option.

iced_video_player's People

Contributors

jazzfool avatar yusdacra avatar

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.