From c36c8189cec207279225fe5e47b653de3c1d7900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 11 Aug 2017 15:31:59 +0300 Subject: [PATCH] Add example to playbin example about how to connect/emit dynamic signals ... and get the audio track's tags whenever they change. --- examples/src/bin/playbin.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/src/bin/playbin.rs b/examples/src/bin/playbin.rs index b0c0b4770..8a9cb192a 100644 --- a/examples/src/bin/playbin.rs +++ b/examples/src/bin/playbin.rs @@ -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::().unwrap(); + let idx = values[1].get::().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::().unwrap(); + + if let Some(artist) = tags.get::() { + println!(" Artist: {}", artist.get().unwrap()); + } + + if let Some(title) = tags.get::() { + println!(" Title: {}", title.get().unwrap()); + } + + if let Some(album) = tags.get::() { + println!(" Album: {}", album.get().unwrap()); + } + + None + }) + .unwrap(); + let bus = playbin.get_bus().unwrap(); let ret = playbin.set_state(gst::State::Playing);