C#中RealPlayer控件axRealAudio有什么方法能够直接读取byte数组中的内容并播放出来不?我想做一个简单的C/S模式的视频点播系统,发送数据的代码如下:
FileStream fs = File.OpenRead(@"C:\Documents and Settings\Administrator\桌面\郭静 - goodbye.mp3");
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
bt = Encoding.UTF32.GetBytes(Convert.ToString(fs.Length));
ns.Write(bt, 0, bt.Length);//ns是NetworkStream类型
ns.Flush();
int i=0;
if (i < buffer.Length - 5000)
{
while (i < buffer.Length - 5000)
{
bt = new byte[5000];
Array.Copy(buffer, i, bt, 0, 5000);
ns.Write(bt, 0, 5000);
i += 5000;
ns.Flush();
}
}
else
{
int n = buffer.Length % 5000;
bt = new byte[n];
Array.Copy(buffer, i, bt, 0, n);
ns.Write(bt, 0, n);
ns.Flush();
}
接收数据我想让axRealAudio控件直接播放接收到的byte数组,有这样的方法吗?
如果有更好的能够实现实时传输的方法,希望大家能告诉我。谢谢了!
FileStream fs = File.OpenRead(@"C:\Documents and Settings\Administrator\桌面\郭静 - goodbye.mp3");
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
bt = Encoding.UTF32.GetBytes(Convert.ToString(fs.Length));
ns.Write(bt, 0, bt.Length);//ns是NetworkStream类型
ns.Flush();
int i=0;
if (i < buffer.Length - 5000)
{
while (i < buffer.Length - 5000)
{
bt = new byte[5000];
Array.Copy(buffer, i, bt, 0, 5000);
ns.Write(bt, 0, 5000);
i += 5000;
ns.Flush();
}
}
else
{
int n = buffer.Length % 5000;
bt = new byte[n];
Array.Copy(buffer, i, bt, 0, n);
ns.Write(bt, 0, n);
ns.Flush();
}
接收数据我想让axRealAudio控件直接播放接收到的byte数组,有这样的方法吗?
如果有更好的能够实现实时传输的方法,希望大家能告诉我。谢谢了!
不过看到的代码,一般都要经过转换才能成为byte数组使用,这可能是C#代码和C++接口只能这样做吧。