Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2debf8d

Browse files
authored
Update README.md
1 parent d467884 commit 2debf8d

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

README.md

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,58 @@
1010
static byte[] buff = new byte[4096];
1111
static int read;
1212
13+
LibraryLoader.Instance.LoadDllDirectory();
14+
1315
string filename = "";
1416
if (args.Count() > 0)
1517
filename = args[0];
16-
else return;
17-
18-
icecast = new Libshout();
19-
icecast.setProtocol(0);
20-
icecast.setHost("127.0.0.1");
21-
icecast.setPort(8000);
22-
icecast.setPassword("hackme");
23-
icecast.setFormat(Libshout.FORMAT_MP3);
24-
icecast.setPublic(true);
25-
icecast.setName("radio");
26-
icecast.setMount("/live");
27-
icecast.open();
28-
29-
//подключились
30-
if (icecast.isConnected())
31-
Console.WriteLine("Connect!");
32-
else Console.WriteLine(icecast.GetError());
33-
34-
//читаем файл
18+
else filename = Path.Combine(Environment.CurrentDirectory, "music.mp3");
19+
20+
//set parameters
21+
icecast = new Libshout();
22+
icecast.Protocol = Libshout.SHOUT_PROTOCOL.SHOUT_PROTOCOL_HTTP;
23+
icecast.Host = "127.0.0.1";
24+
icecast.Port=8000;
25+
icecast.Name = "my super radio";
26+
icecast.Password="hackme";
27+
icecast.Mount= "/example.ogg";
28+
icecast.User= "source";//or "admin"
29+
icecast.Format=Libshout.SHOUT_FORMAT.SHOUT_FORMAT_MP3;
30+
31+
//try open connection
32+
icecast.Open();
33+
34+
if (!icecast.IsConnected())
35+
{
36+
Console.WriteLine(icecast.GetError());
37+
return;
38+
}
39+
40+
Console.WriteLine("Connect!");
41+
42+
//read file
3543
BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));
44+
var lenght = reader.BaseStream.Length;
3645
int total = 0;
46+
var cursor = Console.GetCursorPosition();
3747
while (true)
3848
{
39-
//читаем буфер
40-
read = reader.Read(buff, 0, buff.Length);
49+
//read buffer b
50+
read = reader.Read(buff, 0, buff.Length);
4151
total = total + read;
4252

43-
Console.WriteLine("Position: "+reader.BaseStream.Position);
44-
//если прочитан не весь, то передаем
53+
Console.SetCursorPosition(0, cursor.Top);
54+
Console.WriteLine($"Position: {(total / (double) lenght) * 100:00.00} %");
55+
//if not end, then send buffer to icecast
4556
if (read > 0)
4657
{
47-
icecast.send(buff, read); //пауза, синхронизация внутри метода
58+
icecast.Send(buff, read); //sync inside method
4859
}
49-
else break; //уходим
50-
60+
else break;
5161
}
5262

5363
Console.WriteLine("Done!");
5464
Console.ReadKey(true);
55-
icecast.close();
65+
icecast.Close();
5666
}
5767

0 commit comments

Comments
 (0)