Initial playback
... and not a lot more. Hit play and the podcast will play, press play on something else and that will play instead
This commit is contained in:
committed by
Jordan Petridis
parent
f56bf3afef
commit
09973a6a56
@@ -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"
|
||||
|
||||
+14
-1
@@ -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<Podcast>),
|
||||
RemoveShow(Arc<Podcast>),
|
||||
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(_) => (),
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Action>,
|
||||
) -> 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))]
|
||||
|
||||
Reference in New Issue
Block a user