Fix
authorKhaled Mohammed <khaled.mohammed@gmail.com>
Thu, 7 Sep 2006 16:44:38 +0000 (16:44 +0000)
committerKhaled Mohammed <khaled.mohammed@gmail.com>
Thu, 7 Sep 2006 16:44:38 +0000 (16:44 +0000)
git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@65069 e3ebcda4-bce8-0310-ba0a-eca2169e7518

sample/MP3LaunchParse.cs [new file with mode: 0644]

diff --git a/sample/MP3LaunchParse.cs b/sample/MP3LaunchParse.cs
new file mode 100644 (file)
index 0000000..493d583
--- /dev/null
@@ -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 <mp3 file>\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;
+       }
+}