From 8e330baec03efd9ca0e196819b70748fe1968f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 3 Oct 2009 10:14:44 +0200 Subject: [PATCH] Improve debugging in the gtk-video-player sample and set force-aspect-ratio to TRUE if available --- samples/GtkVideoPlayer.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/samples/GtkVideoPlayer.cs b/samples/GtkVideoPlayer.cs index 395bfffc71..391e4137b0 100644 --- a/samples/GtkVideoPlayer.cs +++ b/samples/GtkVideoPlayer.cs @@ -15,7 +15,7 @@ public class MainWindow : Gtk.Window { HScale _scale; Label _lbl; bool _updatingScale; - bool _pipelineOK; + bool _pipelineOK = false; public static void Main (string[] args) { Gtk.Application.Init (); @@ -128,8 +128,15 @@ public class MainWindow : Gtk.Window { !msg.Structure.Name.Equals ("prepare-xwindow-id")) return; - (msg.Src as XOverlay).XwindowId = _xWindowId; - (msg.Src as XOverlay).HandleEvents (true); + Element src = msg.Src as Element; + if (src == null) + return; + + if (src.HasProperty ("force-aspect-ratio")) + src["force-aspect-ratio"] = true; + + (src as XOverlay).XwindowId = _xWindowId; + (src as XOverlay).HandleEvents (true); }; _playbin.Bus.Message += delegate (object bus, MessageArgs margs) { @@ -159,10 +166,12 @@ public class MainWindow : Gtk.Window { sret = _playbin.GetState (out state, out pending, Clock.Second * 5); } - if (sret == StateChangeReturn.Success) + if (sret == StateChangeReturn.Success) { + Console.WriteLine ("State change successful"); _pipelineOK = true; - else + } else { Console.WriteLine ("State change failed for {0} ({1})\n", dialog.Filename, sret); + } } dialog.Destroy (); @@ -184,12 +193,15 @@ public class MainWindow : Gtk.Window { long duration; Gst.Format fmt = Gst.Format.Time; + Console.WriteLine ("Trying to seek"); if ( (_playbin != null) && _pipelineOK && _playbin.QueryDuration (ref fmt, out duration) && duration != -1) { long pos = (long) (duration * _scale.Value); Console.WriteLine ("Seek to {0}/{1} ({2}%)", pos, duration, _scale.Value); - _playbin.Seek (Format.Time, SeekFlags.Flush | SeekFlags.KeyUnit, pos); + bool ret = _playbin.Seek (Format.Time, SeekFlags.Flush | SeekFlags.KeyUnit, pos); + + Console.WriteLine ("Seeked {0}successfully", (ret ? "" : "not ")); } }