2006-09-07 16:44:38 +00:00
|
|
|
//
|
|
|
|
// Authors
|
|
|
|
// Khaled Mohammed (khaled.mohammed@gmail.com)
|
|
|
|
//
|
|
|
|
// (C) 2006
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using Gst;
|
|
|
|
|
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
public class MP3LaunchParse {
|
|
|
|
static void EventLoop (Element pipe) {
|
|
|
|
Bus bus = pipe.Bus;
|
|
|
|
Message message = null;
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
while (true) {
|
|
|
|
message = bus.Poll (MessageType.Any, -1);
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
if (message == null) {
|
|
|
|
Console.Error.WriteLine ("Message is null!!!");
|
|
|
|
System.Application.Exit();
|
|
|
|
}
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
switch (message.Type) {
|
|
|
|
case MessageType.Eos:
|
|
|
|
message.Dispose();
|
|
|
|
return;
|
|
|
|
case MessageType.Warning:
|
|
|
|
case MessageType.Error:
|
|
|
|
message.Dispose();
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
message.Dispose();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
public static void Main (string [] args) {
|
|
|
|
Application.Init();
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
if (args.Length != 1) {
|
|
|
|
Console.Error.WriteLine ("usage: mono mp3launchparse.exe <mp3 file>\n", args[0]);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
Element bin = (Element) Parse.Launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
|
|
|
|
if (!bin) {
|
|
|
|
Console.Error.WriteLine ("Parse error");
|
|
|
|
Application.Exit();
|
|
|
|
}
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
Bin b = (Bin) bin;
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
Element filesrc = b.GetByName ("my_filesrc");
|
|
|
|
filesrc.SetProperty ("location", args[0]);
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
bin.SetState (State.Playing);
|
2006-09-07 16:44:38 +00:00
|
|
|
|
2009-09-20 08:19:49 +00:00
|
|
|
EventLoop (bin);
|
|
|
|
|
|
|
|
bin.SetState (State.Null);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-07 16:44:38 +00:00
|
|
|
}
|