Skip to content

Instantly share code, notes, and snippets.

@nanase
Last active December 14, 2015 14:49
Show Gist options
  • Save nanase/5103598 to your computer and use it in GitHub Desktop.
Save nanase/5103598 to your computer and use it in GitHub Desktop.
C# でネットラジオ(SHOUTcast, MP3)を聴く。
using System;
using ALSharp;
using Mp3Sharp;
using DevHost.Shoutcast;
namespace NetRadio
{
class MainClass
{
public static void Main (string[] args)
{
// ネットラジオのURL
const string url = "hogehoge.com";
using (var shoutcast = new ShoutcastStream(url))
using (var mp3 = new Mp3Stream(shoutcast))
{
mp3.Read (new byte[0], 0, 0);
var setting = new PlayerSettings ()
{
ChannelCount = mp3.ChannelCount,
SamplingFrequency = mp3.Frequency
};
Console.WriteLine ("URL: {0}", url);
Console.WriteLine ("{0} Hz, 16 bit, {1} channels", mp3.Frequency, mp3.ChannelCount);
shoutcast.StreamTitleChanged += (sender, e) => Console.WriteLine (shoutcast.StreamTitle);
using (var player = new RawWavePlayer(mp3, setting))
Console.ReadKey (true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment