mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
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:
parent
59af28e508
commit
c36c8189ce
1 changed files with 29 additions and 0 deletions
|
@ -30,6 +30,35 @@ fn main() {
|
|||
// .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 ret = playbin.set_state(gst::State::Playing);
|
||||
|
|
Loading…
Reference in a new issue