Click here to Skip to main content
15,905,323 members
Home / Discussions / C#
   

C#

 
AnswerRe: Distinct Row or Rows in a datatable Pin
Mycroft Holmes31-Aug-13 22:42
professionalMycroft Holmes31-Aug-13 22:42 
GeneralRe: Distinct Row or Rows in a datatable Pin
smh13922-Sep-13 10:48
smh13922-Sep-13 10:48 
AnswerRe: Distinct Row or Rows in a datatable Pin
susanna.floora1-Sep-13 19:09
susanna.floora1-Sep-13 19:09 
GeneralRe: Distinct Row or Rows in a datatable Pin
Mycroft Holmes1-Sep-13 19:52
professionalMycroft Holmes1-Sep-13 19:52 
QuestionPut DLL file to another location Pin
Midnight Ahri31-Aug-13 14:43
Midnight Ahri31-Aug-13 14:43 
AnswerRe: Put DLL file to another location Pin
Dave Kreskowiak31-Aug-13 15:10
mveDave Kreskowiak31-Aug-13 15:10 
AnswerRe: Put DLL file to another location Pin
Abhinav S31-Aug-13 15:51
Abhinav S31-Aug-13 15:51 
QuestionHow to get user names accessing ACCESS database Pin
BajrangSingh31-Aug-13 8:22
BajrangSingh31-Aug-13 8:22 
AnswerRe: How to get user names accessing ACCESS database Pin
Dave Kreskowiak31-Aug-13 8:29
mveDave Kreskowiak31-Aug-13 8:29 
GeneralRe: How to get user names accessing ACCESS database Pin
BajrangSingh31-Aug-13 9:32
BajrangSingh31-Aug-13 9:32 
GeneralRe: How to get user names accessing ACCESS database Pin
Dave Kreskowiak31-Aug-13 10:30
mveDave Kreskowiak31-Aug-13 10:30 
GeneralRe: How to get user names accessing ACCESS database Pin
BajrangSingh31-Aug-13 18:40
BajrangSingh31-Aug-13 18:40 
GeneralRe: How to get user names accessing ACCESS database Pin
Dave Kreskowiak1-Sep-13 5:02
mveDave Kreskowiak1-Sep-13 5:02 
AnswerRe: How to get user names accessing ACCESS database Pin
Mycroft Holmes31-Aug-13 13:09
professionalMycroft Holmes31-Aug-13 13:09 
GeneralRe: How to get user names accessing ACCESS database Pin
jschell31-Aug-13 13:57
jschell31-Aug-13 13:57 
GeneralRe: How to get user names accessing ACCESS database Pin
Mycroft Holmes31-Aug-13 16:17
professionalMycroft Holmes31-Aug-13 16:17 
GeneralRe: How to get user names accessing ACCESS database Pin
BajrangSingh31-Aug-13 19:27
BajrangSingh31-Aug-13 19:27 
AnswerRe: How to get user names accessing ACCESS database Pin
Chris Quinn2-Sep-13 4:14
Chris Quinn2-Sep-13 4:14 
QuestionAudio programming - play section of WAV file Pin
keykeeper130-Aug-13 23:04
keykeeper130-Aug-13 23:04 
AnswerRe: Audio programming - play section of WAV file Pin
BillWoodruff31-Aug-13 1:47
professionalBillWoodruff31-Aug-13 1:47 
AnswerRe: Audio programming - play section of WAV file Pin
blitzkrieged31-Aug-13 13:31
blitzkrieged31-Aug-13 13:31 
AnswerRe: Audio programming - play section of WAV file Pin
blitzkrieged31-Aug-13 21:01
blitzkrieged31-Aug-13 21:01 
I remember I played around with playing MP3's a little bit with NAudio, here's a little bit of code that uses NAudio that may help you out...

C#
//Declarations required for audio out and the MP3 stream
IWavePlayer waveOutDevice;

WaveStream mainOutputStream;
WaveChannel32 volumeStream;

string fName = @"song.mp3";

private void Form1_Load(object sender, EventArgs e)
{
    try
    {

        waveOutDevice = new WaveOut();
        
       
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }
}
		
private void btnPlay_Click(object sender, EventArgs e)
{
    try
    {
        if (waveOutDevice.PlaybackState.ToString() == "Playing")
        {
            return;
        }
        
        mainOutputStream = CreateInputStream(fName);
        waveOutDevice.Init(mainOutputStream);
        waveOutDevice.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOutDevice_PlaybackStopped);
        waveOutDevice.Play();

    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }

}

private void waveOutDevice_PlaybackStopped(object sender, EventArgs e)
{
    try
    {
       
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }
}
		
private void btnStop_Click(object sender, EventArgs e)
{
    try
    {
        if (waveOutDevice != null)
        {
            waveOutDevice.Stop();
        }
        if (mainOutputStream != null)
        {
            // this one really closes the file and ACM conversion
            volumeStream.Close();

            // this one does the metering stream
            mainOutputStream.Close();
        }
        if (timerPosition.Enabled)
        {
            timerPosition.Enabled = false;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }
}

private WaveStream CreateInputStream(string fileName)
{
    try
    {
        WaveChannel32 inputStream;
        if (fileName.EndsWith(".mp3"))
        {
            WaveStream mp3Reader = new Mp3FileReader(fileName);
            inputStream = new WaveChannel32(mp3Reader);

        }
        else
        {
            throw new InvalidOperationException("Unsupported extension");
        }
        volumeStream = inputStream;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }
    return volumeStream;
}
private void CloseWaveOut()
{
    try
    {
        if (waveOutDevice != null)
        {
            waveOutDevice.Stop();
        }
        if (mainOutputStream != null)
        {
            // this one really closes the file and ACM conversion
            volumeStream.Close();
            volumeStream = null;

            // this one does the metering stream
            mainOutputStream.Close();
            mainOutputStream = null;
        }
        if (waveOutDevice != null)
        {
            waveOutDevice.Dispose();
            waveOutDevice = null;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, ex.GetType().ToString());
    }
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    CloseWaveOut();
}

AnswerRe: Audio programming - play section of WAV file Pin
Dusara Maulik31-Aug-13 23:27
Dusara Maulik31-Aug-13 23:27 
QuestionCan we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
santosh code30-Aug-13 19:30
santosh code30-Aug-13 19:30 
AnswerRe: Can we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
Pete O'Hanlon30-Aug-13 22:04
mvePete O'Hanlon30-Aug-13 22:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.