From 8342537d123dad3c4a07134e94a212fcc1b6ee27 Mon Sep 17 00:00:00 2001 From: Khaled Mohammed Date: Thu, 7 Sep 2006 16:44:38 +0000 Subject: [PATCH] Fix git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@65069 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- sample/MP3LaunchParse.cs | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sample/MP3LaunchParse.cs diff --git a/sample/MP3LaunchParse.cs b/sample/MP3LaunchParse.cs new file mode 100644 index 0000000000..493d5838a5 --- /dev/null +++ b/sample/MP3LaunchParse.cs @@ -0,0 +1,70 @@ +// +// Authors +// Khaled Mohammed (khaled.mohammed@gmail.com) +// +// (C) 2006 +// + +using System; +using Gst; + + +public class MP3LaunchParse +{ + static void EventLoop (Element pipe) + { + Bus bus = pipe.Bus; + Message message = null; + + while(true) { + message = bus.Poll(MessageType.Any, -1); + + if(message == null) { + Console.Error.WriteLine("Message is null!!!"); + System.Application.Exit(); + } + + switch(message.Type) + { + case MessageType.Eos: + message.Dispose(); + return; + case MessageType.Warning: + case MessageType.Error: + message.Dispose(); + return; + default: + message.Dispose(); + break; + } + } + } + + public static void Main(string [] args) + { + Application.Init(); + + if(args.Length != 1) { + Console.Error.WriteLine("usage: mono mp3launchparse.exe \n", args[0]); + return; + } + + Element bin = (Element) Parse.Launch("filesrc name=my_filesrc ! mad ! osssink", &error); + if(!bin) { + Console.Error.WriteLine("Parse error"); + Application.Exit(); + } + + Bin b = (Bin) bin; + + Element filesrc = b.GetByName("my_filesrc"); + filesrc.SetProperty("location", args[0]); + + bin.SetState(State.Playing); + + EventLoop(bin); + + bin.SetState(State.Null); + return; + } +}