diff --git a/Cargo.lock b/Cargo.lock index c1c50ad..663be4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,6 +701,122 @@ dependencies = [ "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "gstreamer" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "muldiv 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-base" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-base-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-base-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-player" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-player-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-video 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-player-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-video-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-video" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-base 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-base-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-video-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gstreamer-video-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-base-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gtk" version = "0.4.1" @@ -805,6 +921,8 @@ dependencies = [ "gdk-pixbuf 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-player 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "hammond-data 0.1.0", "hammond-downloader 0.1.0", @@ -1185,6 +1303,11 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "muldiv" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "native-tls" version = "0.1.5" @@ -1230,6 +1353,15 @@ dependencies = [ "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num-rational" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.1.43" @@ -2462,6 +2594,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum glib-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615bef979b5838526aee99241afc80cfb2e34a8735d4bcb8ec6072598c18a408" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum gobject-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70409d6405db8b1591602fcd0cbe8af52cd9976dd39194442b4c149ba343f86d" +"checksum gstreamer 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "90d7cde9eae8f6bf4d41c254915976b236143935ec2c0b027636274e998e54b4" +"checksum gstreamer-base 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05ec7a84b4160b61c72ea27ccf3f46eb9c8f996c5991746623e69e3e532e3cb5" +"checksum gstreamer-base-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "501a7add44f256aab6cb5b65ef121c449197cf55087d6a7586846c8d1e42e88b" +"checksum gstreamer-player 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d831e2c4aa1296a8d0f3b4caa0b5ae8d6f5c0eed67ed20236f8647010005c63e" +"checksum gstreamer-player-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b9476078cc76164446e88b2c4331e81e24a07f7b7c3a8b4bf8975a47998ebd4" +"checksum gstreamer-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b2f51e25a6f97dd4bfd640cba96f192f8759b8766afd66d6d9ea0f82ca14a37" +"checksum gstreamer-video 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76c6c8971688f530ae93e96ea29fe6051658bb4d00b4b40d30575ca1d8a25a18" +"checksum gstreamer-video-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ed798787e78a0f1c8be06bd3adcab03f962f049a820743aae9f690f56a0d538" "checksum gtk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d695d6be4110618a97c19cd068e8a00e53e33b87e3c65cdc5397667498b1bc24" "checksum gtk-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d9554cf5b3a85a13fb39258c65b04b262989c1d7a758f8f555b77a478621a91" "checksum handlebars 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7bdb08e879b8c78ee90f5022d121897c31ea022cb0cc6d13f2158c7a9fbabb1" @@ -2503,11 +2643,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mime_guess 2.0.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130ea3c9c1b65dba905ab5a4d9ac59234a9585c24d135f264e187fe7336febbd" "checksum mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "6d771e3ef92d58a8da8df7d6976bfca9371ed1de6619d9d5a5ce5b1f29b85bfe" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum muldiv 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1cbef5aa2e8cd82a18cc20e26434cc9843e1ef46e55bfabe5bddb022236c5b3e" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" "checksum net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "9044faf1413a1057267be51b5afba8eb1090bd2231c693664aa1db716fe1eae0" "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac0ea58d64a89d9d6b7688031b3be9358d6c919badcf7fbb0527ccfd891ee45" +"checksum num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e" "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" diff --git a/hammond-gtk/Cargo.toml b/hammond-gtk/Cargo.toml index 76169ce..7619360 100644 --- a/hammond-gtk/Cargo.toml +++ b/hammond-gtk/Cargo.toml @@ -11,6 +11,8 @@ crossbeam-channel = "0.1.2" gdk = "0.8.0" gdk-pixbuf = "0.4.0" glib = "0.5.0" +gstreamer = "0.11.2" +gstreamer-player = "0.11.0" humansize = "1.1.0" lazy_static = "1.0.0" log = "0.4.1" diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 3d9f4fb..711c004 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -5,6 +5,7 @@ use gio::{ SimpleAction, SimpleActionExt, }; use glib; +use gstreamer_player as gst; use gtk; use gtk::prelude::*; use gtk::SettingsExt as GtkSettingsExt; @@ -53,6 +54,7 @@ pub enum Action { MarkAllPlayerNotification(Arc), RemoveShow(Arc), ErrorNotification(String), + PlayEpisode(String) } #[derive(Debug)] @@ -127,6 +129,12 @@ impl App { window.show_all(); window.activate(); + let player = gst::Player::new(None, None); + player.connect_error(clone!(sender => move |_,err| { + // Not the most user friendly... + sender.send(Action::ErrorNotification(format!("Playback: {}", err))).ok(); + })); + gtk::timeout_add(50, clone!(sender, receiver => move || { // Uses receiver, content, header, sender, overlay match receiver.try_recv() { @@ -183,7 +191,12 @@ impl App { let notif = InAppNotification::new(&err, callback, || {}, UndoState::Hidden); notif.show(&overlay); - } + }, + Ok(Action::PlayEpisode(uri)) => { + // This must be a 'real' (file://) uri not a path + player.set_uri(&uri); + player.play(); + }, Err(_) => (), } diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs index a102303..e5d6d6a 100644 --- a/hammond-gtk/src/main.rs +++ b/hammond-gtk/src/main.rs @@ -10,6 +10,8 @@ extern crate gdk; extern crate gdk_pixbuf; extern crate gio; extern crate glib; +extern crate gstreamer; +extern crate gstreamer_player; extern crate gtk; #[macro_use] @@ -42,6 +44,7 @@ extern crate url; use log::Level; +use gstreamer as gst; use gtk::prelude::*; // http://gtk-rs.org/tuto/closures @@ -80,6 +83,7 @@ fn main() { // TODO: make the the logger a cli -vv option loggerv::init_with_level(Level::Info).expect("Error initializing loggerv."); gtk::init().expect("Error initializing gtk."); + gst::init().expect("Error initializing gstreamer"); static_resource::init().expect("Something went wrong with the resource file initialization."); // Add custom style diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index b7cfde3..581eecd 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -1,3 +1,4 @@ +use gio::{File, FileExt}; use glib; use gtk; use gtk::prelude::*; @@ -7,6 +8,7 @@ use chrono::prelude::*; use crossbeam_channel::Sender; use failure::Error; use humansize::{file_size_opts as size_opts, FileSize}; +#[allow(unused_imports)] use open; use hammond_data::dbqueries; @@ -446,15 +448,24 @@ fn on_play_bttn_clicked( episode: &mut EpisodeWidgetQuery, sender: &Sender, ) -> Result<(), Error> { - open_uri(episode.rowid())?; - episode.set_played_now()?; + let uri = dbqueries::get_episode_local_uri_from_id(episode.rowid())? + .ok_or_else(|| format_err!("Expected Some found None."))?; + let p = Path::new(&uri); + if p.exists() { + info!("Opening {}", uri); + // uri is actually a path, convert it (hacky) + let uri = File::new_for_path(p).get_uri().expect("Bad file path"); + sender.send(Action::PlayEpisode(uri)).ok(); + } else { + bail!("File \"{}\" does not exist.", uri); + } widget.info.set_title(&episode); sender .send(Action::RefreshEpisodesViewBGR) .map_err(From::from) } - +/* fn open_uri(rowid: i32) -> Result<(), Error> { let uri = dbqueries::get_episode_local_uri_from_id(rowid)? .ok_or_else(|| format_err!("Expected Some found None."))?; @@ -468,7 +479,7 @@ fn open_uri(rowid: i32) -> Result<(), Error> { Ok(()) } - +*/ // Setup a callback that will update the progress bar. #[inline] #[cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))] diff --git a/org.gnome.Hammond.json b/org.gnome.Hammond.json index 8e27d4f..6b305d8 100644 --- a/org.gnome.Hammond.json +++ b/org.gnome.Hammond.json @@ -20,6 +20,7 @@ "--share=ipc", "--socket=x11", "--socket=wayland", + "--socket=pulseaudio", "--talk-name=org.freedesktop.Desktop" ], "build-options" : {