Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Can we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
santosh code31-Aug-13 0:34
santosh code31-Aug-13 0:34 
Question[Solved] Run application until Tasks are finished? Pin
Dralken30-Aug-13 13:54
Dralken30-Aug-13 13:54 
AnswerRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 14:57
mveDave Kreskowiak30-Aug-13 14:57 
GeneralRe: Run application until Tasks are finished? Pin
Dralken30-Aug-13 15:16
Dralken30-Aug-13 15:16 
GeneralRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 15:28
mveDave Kreskowiak30-Aug-13 15:28 
GeneralRe: Run application until Tasks are finished? Pin
Dralken31-Aug-13 1:26
Dralken31-Aug-13 1:26 
GeneralRe: Run application until Tasks are finished? Pin
BillWoodruff1-Sep-13 19:51
professionalBillWoodruff1-Sep-13 19:51 
GeneralRe: Run application until Tasks are finished? Pin
Dralken1-Sep-13 20:40
Dralken1-Sep-13 20:40 
SuggestionRe: Run application until Tasks are finished? Pin
Keith L Robertson3-Sep-13 5:27
Keith L Robertson3-Sep-13 5:27 
QuestionHow to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT29-Aug-13 23:16
vikash kumar NIIT29-Aug-13 23:16 
SuggestionRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 1:38
mveRichard Deeming30-Aug-13 1:38 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT30-Aug-13 1:50
vikash kumar NIIT30-Aug-13 1:50 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
davidstein30-Aug-13 3:06
davidstein30-Aug-13 3:06 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 3:21
mveRichard Deeming30-Aug-13 3:21 

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.