2002-11-01 05:10:00 +00:00
|
|
|
// GstPlayer.cs - a simple Vorbis media player using GStreamer
|
|
|
|
//
|
|
|
|
// Author: Alp Toker <alp@atoker.com>
|
|
|
|
//
|
|
|
|
// Copyright (c) 2002 Alp Toker
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using Gst;
|
|
|
|
|
|
|
|
public class GstTest
|
|
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
|
|
|
Application.Init ();
|
|
|
|
|
|
|
|
/* create a new bin to hold the elements */
|
|
|
|
Pipeline bin = new Pipeline("pipeline");
|
|
|
|
|
|
|
|
/* create a disk reader */
|
|
|
|
Element filesrc = ElementFactory.Make ("filesrc", "disk_source");
|
2003-11-04 23:45:04 +00:00
|
|
|
filesrc.SetProperty ("location", args[0]);
|
2002-11-01 05:10:00 +00:00
|
|
|
|
|
|
|
/* now it's time to get the decoder */
|
2003-11-04 23:45:04 +00:00
|
|
|
Element decoder = ElementFactory.Make ("vorbisfile", "decode");
|
2002-11-01 05:10:00 +00:00
|
|
|
|
|
|
|
/* and an audio sink */
|
|
|
|
Element osssink = ElementFactory.Make ("osssink", "play_audio");
|
|
|
|
|
|
|
|
/* add objects to the main pipeline */
|
|
|
|
bin.Add (filesrc);
|
|
|
|
bin.Add (decoder);
|
|
|
|
bin.Add (osssink);
|
|
|
|
|
|
|
|
/* connect the elements */
|
2003-11-04 23:45:04 +00:00
|
|
|
filesrc.Link (decoder);
|
|
|
|
decoder.Link (osssink);
|
2002-11-01 05:10:00 +00:00
|
|
|
|
|
|
|
/* start playing */
|
|
|
|
bin.SetState (ElementState.Playing);
|
|
|
|
|
|
|
|
while (bin.Iterate ());
|
|
|
|
|
|
|
|
/* stop the bin */
|
|
|
|
bin.SetState (ElementState.Null);
|
|
|
|
}
|
|
|
|
}
|