From 50c70e06b2b8f4f24da6287c5affaa8086e79a99 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 14 Jun 2018 09:24:24 +0300 Subject: [PATCH] PlayerWidget: Set a custom config for the gst Player. --- hammond-data/src/lib.rs | 4 +++- hammond-gtk/src/widgets/player.rs | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hammond-data/src/lib.rs b/hammond-data/src/lib.rs index 336c999..414ab60 100644 --- a/hammond-data/src/lib.rs +++ b/hammond-data/src/lib.rs @@ -81,7 +81,9 @@ pub use models::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source // Set the user agent, See #53 for more // Keep this in sync with Tor-browser releases -const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0"; +/// The user-agent to be used for all the requests. +/// It originates from the Tor-browser UA. +pub const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0"; /// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths. #[allow(missing_debug_implementations)] diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 6e47555..c81eb92 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -11,7 +11,7 @@ use gtk::prelude::*; use failure::Error; -use hammond_data::dbqueries; +use hammond_data::{dbqueries, USER_AGENTR}; use hammond_data::{EpisodeWidgetQuery, PodcastCoverQuery}; use utils::set_image_from_path; @@ -98,8 +98,14 @@ pub struct PlayerWidget { impl Default for PlayerWidget { fn default() -> Self { - let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/player_toolbar.ui"); let player = gst_player::Player::new(None, None); + + let mut config = player.get_config(); + config.set_user_agent(USER_AGENT); + config.set_position_update_interval(250); + player.set_config(config).unwrap(); + + let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/player_toolbar.ui"); let action_bar = builder.get_object("action_bar").unwrap(); let buttons = builder.get_object("buttons").unwrap();