Compare commits

..

12 Commits

Author SHA1 Message Date
71f7d02f7a remove nikolor because it's not supposed to be here.
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2022-09-21 01:04:15 +01:00
cbc302914a GStramer implementation, it plays videos, nice!
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2022-09-21 01:01:37 +01:00
88f3cae2cf woodpecker fix2
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-09-12 22:17:14 +01:00
4d6dde1727 Yeah no i'll fix the compiler this is getting annoying
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2022-09-11 15:11:25 +01:00
9cccb7af89 Ignore Cargo.lock
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-09-11 15:08:55 +01:00
b77c0cf50c Remove Cargo.lock 2022-09-11 15:08:40 +01:00
2858158277 Figured out a ton of things now, Let's make an actual UI this time! 2022-09-11 15:05:26 +01:00
61dd0f22a9 wood pecker
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-09-10 16:45:18 +01:00
aaabc484ad json parsing works, and invidious extra works, yay??
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-09-10 16:32:54 +01:00
f8bc34a93d trigger CI
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-09-08 13:11:10 +01:00
80b37cc348 wooooo 2022-09-08 13:10:23 +01:00
fa650374de Readme stay here 2022-09-08 11:35:17 +01:00
7 changed files with 179 additions and 18 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/target
Cargo.lock

23
.woodpecker.yml Normal file
View File

@@ -0,0 +1,23 @@
pipeline:
build:
when:
event: [push, pull_request]
image: ghcr.io/13hannes11/gtk4-rs-docker:latest-appimage
commands:
- cargo update
- cargo build
- cargo test
- echo "Done building!"
gzip:
when:
event: [push]
image: rust:latest
commands:
- mkdir ../artifact
- mv target/debug ../artifact
- tar -c -z -v -f gtubek-dev.tar.gz ../artifact
#upload:
#when:
#event: [push]
#image:

View File

@@ -1,6 +1,6 @@
[package]
name = "gtk-hello"
version = "0.1.0"
name = "gtubek"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -9,4 +9,12 @@ edition = "2021"
gtk = { version = "0.4.8", package = "gtk4" }
adw = { version = "0.1.1", package = "libadwaita" }
invidious = "0.3.2"
gtk-ui-builder = "0.2.0"
gtk-ui-builder = "0.2.0"
serde_json = "1.0"
gst = { version = "0.18.8", package = "gstreamer" }
anyhow = "1.0.65"
glib = "0.15.12"
gst-plugin-reqwest = "0.8.0"
[profile.release]
strip = true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

View File

@@ -1,10 +1,12 @@
use invidious::reqwest::blocking::Client;
use std::error::Error;
//use serde::{Deserialize, Serialize};
//use serde_json::Result;
pub fn inv() -> Result<(), Box<dyn Error>> {
let client = Client::new(String::from("https://vid.puffyan.us"));
let search_results = client.search(Some("q=rust programming"))?.items;
let video = client.video("5C_HPTJg5ek", None)?;
print!("{:?}", video);
Ok(())
pub fn inv() -> Result<String, Box<dyn Error>> {
let client = Client::new(String::from("https://invidious.projectsegfau.lt"));
let output = &client.video("5C_HPTJg5ek", None)?.format_streams[2].url;
println!("{}", output);
Ok(output.to_string())
}

View File

@@ -5,8 +5,11 @@ use gtk::gio;
use std::fs::File;
use std::path::Path;
use gtk::prelude::*;
use gtk::{self, ApplicationWindow, Button, prelude::*};
use crate::inv::inv;
use gtk::{self, ApplicationWindow, Button, prelude::*, ListBox, FlowBox, PolicyType, ScrolledWindow, Box, Orientation, Align::*};
use gst::prelude::*;
use std::io::Write;
use anyhow::Error;
use crate::inv::*;
mod inv;
@@ -18,37 +21,160 @@ fn main() {
// Connect to "activate" signal of `app`
app.connect_activate(build_ui);
let output = inv::inv();
print!("{:?}", output);
inv();
//print!("{:?}", output);
// Run the application
match VidPlayer() {
Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err),
}
app.run();
}
fn build_ui(app: &Application) {
// Create a button
let button = Button::builder()
.label("Press me!")
.icon_name("fingerprint-authentication-symbolic")
.valign(Fill)
.vexpand(true)
.margin_top(12)
.margin_bottom(12)
.margin_start(12)
.margin_end(12)
.build();
//button.connect_clicked(move |_| trig_play());
let video = Video::for_file(Some(&gio::File::for_path("/home/midou/Vidéos/miui.mp4")));
//let output = inv::inv();
//let video = Video::for_media_stream(Some(&output));
/*
// Set a listBox
let listbox = ListBox::builder()
.child(&video)
.build();
*/
// Set a box
let boxy = Box::new(Orientation::Vertical, 0);
boxy.append(&video);
boxy.append(&button);
// Then make the window scrollable
let scrolled_window = ScrolledWindow::builder()
// .hscrollbar_policy(PolicyType::Never) // Disable horizontal scrolling
// .hscrollbar_policy()
.min_content_width(360)
.child(&boxy)
.build();
// Create a window
let window = ApplicationWindow::builder()
.application(app)
.default_width(1280)
.default_height(720)
.title("My GTK App")
.child(&button)
.child(&video)
.child(&scrolled_window)
.build();
// Present window
window.present();
}
//fn trig_play() {
// let trigger =
//}
use gst::prelude::*;
fn VidPlayer() -> Result<(), Error> {
// Initialize GStreamer
gst::init()?;
// Build the pipeline
//let uri =
//"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let uri = inv().unwrap();
println!("{:?}", uri);
let pipeline = gst::parse_launch(&format!("playbin uri={:?}", uri))?;
// Start playing
let res = pipeline.set_state(gst::State::Playing)?;
let is_live = res == gst::StateChangeSuccess::NoPreroll;
let main_loop = glib::MainLoop::new(None, false);
let main_loop_clone = main_loop.clone();
let pipeline_weak = pipeline.downgrade();
let bus = pipeline.bus().expect("Pipeline has no bus");
bus.add_watch(move |_, msg| {
let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline,
None => return glib::Continue(true),
};
let main_loop = &main_loop_clone;
match msg.view() {
gst::MessageView::Error(err) => {
println!(
"Error from {:?}: {} ({:?})",
err.src().map(|s| s.path_string()),
err.error(),
err.debug()
);
let _ = pipeline.set_state(gst::State::Ready);
main_loop.quit();
}
gst::MessageView::Eos(..) => {
// end-of-stream
let _ = pipeline.set_state(gst::State::Ready);
main_loop.quit();
}
gst::MessageView::Buffering(buffering) => {
// If the stream is live, we do not care about buffering
if is_live {
return glib::Continue(true);
}
let percent = buffering.percent();
print!("Buffering ({}%)\r", percent);
match std::io::stdout().flush() {
Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err),
};
// Wait until buffering is complete before start/resume playing
if percent < 100 {
let _ = pipeline.set_state(gst::State::Paused);
} else {
let _ = pipeline.set_state(gst::State::Playing);
}
}
gst::MessageView::ClockLost(_) => {
// Get a new clock
let _ = pipeline.set_state(gst::State::Paused);
let _ = pipeline.set_state(gst::State::Playing);
}
_ => (),
}
glib::Continue(true)
})
.expect("Failed to add bus watch");
main_loop.run();
bus.remove_watch()?;
pipeline.set_state(gst::State::Null)?;
Ok(())
}