#!/usr/bin/env ruby # encoding: utf-8 require "gst" if ARGV.length < 1 puts "usage: #{$0} " exit(false) end Gst.init playbin = Gst::ElementFactory.make("playbin") if playbin.nil? puts "'playbin' gstreamer plugin missing" exit(false) end # take the commandline argument and ensure that it is a uri if Gst.valid_uri?(ARGV.first) uri = ARGV.first else uri = Gst.filename_to_uri(ARGV.first) end playbin.uri = uri # create and event loop feed gstreamer bus messages to it loop = GLib::MainLoop.new bus = playbin.bus =begin bus.add_watch do |bus, message| case message.type when Gst::MessageType::EOS puts "End-of-stream" loop.quit when Gst::MessageType::ERROR error, debug = message.parse_error puts "Debugging info: #{debug || 'none'}" puts "Error: #{error.message}" loop.quit when Gst::MessageType::TAG p "tag" end true end =end # start play back and listed to events #playbin.play playbin.pause sleep 1 p "slept" tags=Gst::TagList.new while message=bus.pop if message.type==Gst::MessageType::TAG #parse_tag return a array. Why? Can it return more than 1 list. If not change behaviour. #tags.merge(message.parse_tag.first, Gst::TagMergeMode::KEEP)#Does not merge p "TAG" tags=message.parse_tag.first end end tags.n_tags.times{|i| p tags.nth_tag_name(i)} if tags.empty? puts "No metadata found for #{}" else #tags.each do |tag|#TODO rename for all methods foreach. Not only for Gst::TagList tags.foreach do |tag|#gobject-introspection/loader.rb:256:in `invoke': TODO: func callback is not supported yet. (NotImplementedError) p tag end end begin loop.run rescue Interrupt puts "Interrupt" rescue => error puts "Error: #{error.message}" ensure playbin.stop end