update iced to 0.13, v0.4
This commit is contained in:
parent
65f9cc5a5d
commit
61b083929e
6 changed files with 1151 additions and 256 deletions
1349
Cargo.lock
generated
1349
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ repository = "https://github.com/jazzfool/iced_video_player"
|
|||
readme = "README.md"
|
||||
keywords = ["gui", "iced", "video"]
|
||||
categories = ["gui", "multimedia"]
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = ["jazzfool"]
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
|
@ -16,9 +16,9 @@ exclude = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
iced = { version = "0.12", features = ["image", "advanced", "wgpu"] }
|
||||
iced = { version = "0.13", features = ["image", "advanced", "wgpu"] }
|
||||
iced_native = "0.10"
|
||||
iced_wgpu = "0.12"
|
||||
iced_wgpu = "0.13"
|
||||
gstreamer = "0.22"
|
||||
gstreamer-app = "0.22" # appsink
|
||||
gstreamer-base = "0.22" # basesrc
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use iced::{
|
||||
widget::{Button, Column, Row, Slider, Text},
|
||||
Element, Sandbox,
|
||||
Element,
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
App::run(Default::default()).unwrap();
|
||||
fn main() -> iced::Result {
|
||||
iced::run("Iced Video Player", App::update, App::view)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -25,10 +25,8 @@ struct App {
|
|||
dragging: bool,
|
||||
}
|
||||
|
||||
impl Sandbox for App {
|
||||
type Message = Message;
|
||||
|
||||
fn new() -> Self {
|
||||
impl Default for App {
|
||||
fn default() -> Self {
|
||||
let video = Video::new(
|
||||
&url::Url::from_file_path(
|
||||
std::path::PathBuf::from(file!())
|
||||
|
@ -47,11 +45,9 @@ impl Sandbox for App {
|
|||
dragging: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
String::from("Video Player")
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::TogglePause => {
|
||||
|
@ -93,6 +89,8 @@ impl Sandbox for App {
|
|||
.push(
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.align_y(iced::alignment::Vertical::Center)
|
||||
.padding(iced::Padding::new(5.0))
|
||||
.push(
|
||||
Button::new(Text::new(if self.video.paused() {
|
||||
"Play"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use iced_wgpu::primitive::pipeline::Primitive;
|
||||
use iced_wgpu::primitive::Primitive;
|
||||
use iced_wgpu::wgpu;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
|
@ -204,7 +204,7 @@ impl VideoPipeline {
|
|||
);
|
||||
}
|
||||
|
||||
fn prepare(&mut self, queue: &wgpu::Queue, video_id: u64, bounds: iced::Rectangle) {
|
||||
fn prepare(&mut self, queue: &wgpu::Queue, video_id: u64, bounds: &iced::Rectangle) {
|
||||
if let Some((_, buffer, _)) = self.textures.get(&video_id) {
|
||||
let uniforms = Uniforms {
|
||||
rect: [
|
||||
|
@ -227,7 +227,7 @@ impl VideoPipeline {
|
|||
&self,
|
||||
target: &wgpu::TextureView,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
viewport: iced::Rectangle<u32>,
|
||||
viewport: &iced::Rectangle<u32>,
|
||||
video_id: u64,
|
||||
) {
|
||||
if let Some((_, _, bind_group)) = self.textures.get(&video_id) {
|
||||
|
@ -288,13 +288,12 @@ impl VideoPrimitive {
|
|||
impl Primitive for VideoPrimitive {
|
||||
fn prepare(
|
||||
&self,
|
||||
format: wgpu::TextureFormat,
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
bounds: iced::Rectangle,
|
||||
_target_size: iced::Size<u32>,
|
||||
_scale_factor: f32,
|
||||
storage: &mut iced_wgpu::primitive::pipeline::Storage,
|
||||
format: wgpu::TextureFormat,
|
||||
storage: &mut iced_wgpu::primitive::Storage,
|
||||
bounds: &iced::Rectangle,
|
||||
_viewport: &iced_wgpu::graphics::Viewport,
|
||||
) {
|
||||
if !storage.has::<VideoPipeline>() {
|
||||
storage.store(VideoPipeline::new(device, format));
|
||||
|
@ -317,13 +316,12 @@ impl Primitive for VideoPrimitive {
|
|||
|
||||
fn render(
|
||||
&self,
|
||||
storage: &iced_wgpu::primitive::pipeline::Storage,
|
||||
target: &wgpu::TextureView,
|
||||
_target_size: iced::Size<u32>,
|
||||
viewport: iced::Rectangle<u32>,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
storage: &iced_wgpu::primitive::Storage,
|
||||
target: &wgpu::TextureView,
|
||||
clip_bounds: &iced::Rectangle<u32>,
|
||||
) {
|
||||
let pipeline = storage.get::<VideoPipeline>().unwrap();
|
||||
pipeline.draw(target, encoder, viewport, self.video_id);
|
||||
pipeline.draw(target, encoder, clip_bounds, self.video_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ impl Video {
|
|||
// maybe in a small window between seek and wait the old frame comes in?
|
||||
inner.wait.recv().map_err(|_| Error::Sync)?;
|
||||
inner.wait.recv().map_err(|_| Error::Sync)?;
|
||||
Ok(img::Handle::from_pixels(
|
||||
Ok(img::Handle::from_rgba(
|
||||
inner.width as _,
|
||||
inner.height as _,
|
||||
self.0
|
||||
|
|
|
@ -4,7 +4,7 @@ use iced::{
|
|||
advanced::{self, graphics::core::event::Status, layout, widget, Widget},
|
||||
Element,
|
||||
};
|
||||
use iced_wgpu::primitive::pipeline::Renderer as PrimitiveRenderer;
|
||||
use iced_wgpu::primitive::Renderer as PrimitiveRenderer;
|
||||
use log::error;
|
||||
use std::{marker::PhantomData, sync::atomic::Ordering};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
@ -111,7 +111,7 @@ where
|
|||
_viewport: &iced::Rectangle,
|
||||
) {
|
||||
let inner = self.video.0.borrow();
|
||||
renderer.draw_pipeline_primitive(
|
||||
renderer.draw_primitive(
|
||||
layout.bounds(),
|
||||
VideoPrimitive::new(
|
||||
inner.id,
|
||||
|
@ -135,7 +135,7 @@ where
|
|||
) -> Status {
|
||||
let mut inner = self.video.0.borrow_mut();
|
||||
|
||||
if let iced::Event::Window(_, iced::window::Event::RedrawRequested(now)) = event {
|
||||
if let iced::Event::Window(iced::window::Event::RedrawRequested(now)) = event {
|
||||
if inner.restart_stream || (!inner.is_eos && !inner.paused) {
|
||||
let mut restart_stream = false;
|
||||
if inner.restart_stream {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue