Add example to playbin example about how to connect/emit dynamic signals

... and get the audio track's tags whenever they change.
This commit is contained in:
Sebastian Dröge 2017-08-11 15:31:59 +03:00
parent 59af28e508
commit c36c8189ce

View file

@ -30,6 +30,35 @@ fn main() {
// .unwrap(); // .unwrap();
// playbin.set_property("flags", &flags).unwrap(); // playbin.set_property("flags", &flags).unwrap();
playbin
.connect("audio-tags-changed", false, |values| {
let playbin = values[0].get::<glib::Object>().unwrap();
let idx = values[1].get::<i32>().unwrap();
println!("audio tags of audio stream {} changed:", idx);
let tags = playbin
.emit("get-audio-tags", &[&idx.to_value()])
.unwrap()
.unwrap();
let tags = tags.get::<TagList>().unwrap();
if let Some(artist) = tags.get::<tags::Artist>() {
println!(" Artist: {}", artist.get().unwrap());
}
if let Some(title) = tags.get::<tags::Title>() {
println!(" Title: {}", title.get().unwrap());
}
if let Some(album) = tags.get::<tags::Album>() {
println!(" Album: {}", album.get().unwrap());
}
None
})
.unwrap();
let bus = playbin.get_bus().unwrap(); let bus = playbin.get_bus().unwrap();
let ret = playbin.set_state(gst::State::Playing); let ret = playbin.set_state(gst::State::Playing);