TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Choudhary
NA
5
7.8k
how do i play mp3 file from array of bytes
Dec 27 2013 10:11 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
public static void Main(string[] args)
{
string _FileName = "C:\\rah\\Enya.mp3";
byte[] p;
p=File.ReadAllBytes(_FileName);
byte[] Stm = StereoToMono(p);
for(int i=0;i<Stm.Length;i++)
{
Console.Out.WriteLine(Stm[i]);
}
Console.ReadKey();
}
public static byte[] StereoToMono(byte[] input)
{
byte[] output = new byte[input.Length / 2];
int outputIndex = 0;
try
{
for (int n = 0; n < input.Length; n += 4)
{
// copy in the first 16 bit sample
output[outputIndex++] = input[n];
output[outputIndex++] = input[n + 1];
}
}
catch (Exception e)
{ return output; }
return output;
}
private byte[] MonoToStereo(byte[] input)
{
byte[] output = new byte[input.Length * 2];
int outputIndex = 0;
try
{
for (int n = 0; n < input.Length; n += 2)
{
// copy in the first 16 bit sample
output[outputIndex++] = input[n];
output[outputIndex++] = input[n + 1];
// now copy it in again
output[outputIndex++] = input[n];
output[outputIndex++] = input[n + 1];
}
}
catch (Exception e)
{ return output; }
return output;
}
}
}
Reply
Answers (
0
)
My Code
Tailspin spyworks try catch error