mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-23 03:50:59 +00:00
Improve togglerecord example UI a bit
This commit is contained in:
parent
c6800e8a26
commit
9250ca4ccc
1 changed files with 5 additions and 5 deletions
|
@ -205,14 +205,14 @@ fn create_ui(app: >k::Application) {
|
||||||
hbox.pack_start(&position_label, true, true, 5);
|
hbox.pack_start(&position_label, true, true, 5);
|
||||||
let recorded_duration_label = gtk::Label::new("Recorded: 00:00:00");
|
let recorded_duration_label = gtk::Label::new("Recorded: 00:00:00");
|
||||||
hbox.pack_start(&recorded_duration_label, true, true, 5);
|
hbox.pack_start(&recorded_duration_label, true, true, 5);
|
||||||
vbox.pack_start(&hbox, true, true, 5);
|
vbox.pack_start(&hbox, false, false, 5);
|
||||||
|
|
||||||
let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
||||||
let record_button = gtk::Button::new_with_label("Record");
|
let record_button = gtk::Button::new_with_label("Record");
|
||||||
hbox.pack_start(&record_button, true, true, 5);
|
hbox.pack_start(&record_button, true, true, 5);
|
||||||
let finish_button = gtk::Button::new_with_label("Finish");
|
let finish_button = gtk::Button::new_with_label("Finish");
|
||||||
hbox.pack_start(&finish_button, true, true, 5);
|
hbox.pack_start(&finish_button, true, true, 5);
|
||||||
vbox.pack_start(&hbox, true, true, 5);
|
vbox.pack_start(&hbox, false, false, 5);
|
||||||
|
|
||||||
window.add(&vbox);
|
window.add(&vbox);
|
||||||
window.show_all();
|
window.show_all();
|
||||||
|
@ -221,18 +221,18 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let video_sink_clone = video_sink.clone();
|
let video_sink_clone = video_sink.clone();
|
||||||
let togglerecord_clone = togglerecord.clone();
|
let togglerecord_clone = togglerecord.clone();
|
||||||
gtk::timeout_add(500, move || {
|
gtk::timeout_add(100, move || {
|
||||||
let video_sink = &video_sink_clone;
|
let video_sink = &video_sink_clone;
|
||||||
let togglerecord = &togglerecord_clone;
|
let togglerecord = &togglerecord_clone;
|
||||||
|
|
||||||
let position = video_sink.query_position::<gst::ClockTime>().unwrap_or(0.into());
|
let position = video_sink.query_position::<gst::ClockTime>().unwrap_or(0.into());
|
||||||
position_label.set_text(&format!("Position: {:.0}", position));
|
position_label.set_text(&format!("Position: {:.1}", position));
|
||||||
|
|
||||||
let recording_duration = togglerecord
|
let recording_duration = togglerecord
|
||||||
.get_static_pad("src")
|
.get_static_pad("src")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.query_position::<gst::ClockTime>().unwrap_or(0.into());
|
.query_position::<gst::ClockTime>().unwrap_or(0.into());
|
||||||
recorded_duration_label.set_text(&format!("Recorded: {:.0}", recording_duration));
|
recorded_duration_label.set_text(&format!("Recorded: {:.1}", recording_duration));
|
||||||
|
|
||||||
glib::Continue(true)
|
glib::Continue(true)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue