blob: 9dcbe64dc1b21c79421f07ed063c16059fd00497 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
using System;
using GLib;
using Gst;
public class PlayBinPlayer
{
private static MainLoop loop;
private static string[] songs;
private static int song_idx = 0;
private static PlayBin play;
public static void Main (string[] args)
{
if (args.Length < 1) {
Console.WriteLine ("usage: mono playbin-player.exe audio_file_uri");
return;
}
songs = args;
Gst.Application.Init ();
loop = new MainLoop ();
play = ElementFactory.Make ("playbin", "play") as PlayBin;
if (play == null) {
Console.WriteLine ("error creating a playbin gstreamer object");
return;
}
play.Uri = songs[song_idx++];
play.Bus.AddWatch (new BusFunc (BusCb));
play.SetState (State.Playing);
loop.Run ();
}
private static bool BusCb (Bus bus, Message message)
{
switch (message.Type) {
case MessageType.Error:
string err = String.Empty;
message.ParseError (out err);
Console.WriteLine ("Gstreamer error: {0}", err);
loop.Quit ();
break;
case MessageType.Eos:
if (song_idx >= songs.Length) {
Console.WriteLine ("Thank you, come again");
loop.Quit ();
} else {
play.SetState (State.Null);
play.Uri = songs[song_idx++];
play.SetState (State.Playing);
}
break;
}
return true;
}
}
|