Click here to Skip to main content
15,881,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i open it and try to record my voice and listen my voice it works perfectly but i cant record my voice second time.it plays the voice which i have recorded before the last one.
this is my code.i hope i could tell my problem.
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("winmm.dll", EntryPoint = "mciSendStringA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern int record(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); 
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            record("open new Type waveaudio Alias recsound", "", 0, 0);
            record("record recsound", "", 0, 0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            record("save recsound C:\\Users\\oguzhan\\Desktop\\ddd.wav", "", 0, 0);
            record("close recsound", "", 0, 0);
            axWindowsMediaPlayer1.URL = "C:\\Users\\oguzhan\\Desktop\\ddd.wav";
            axWindowsMediaPlayer1.Ctlcontrols.play();    
        }              
    }
}
Posted
Updated 10-Oct-15 10:00am
v3
Comments
Zoltán Zörgő 10-Oct-15 16:22pm    
I think you should close media player object to release media file.
Oğuzhan Kalsın 11-Oct-15 5:36am    
yea it solved the problem but now the records are getting together.how can i clear the previus one ?
ChrisCreateBoss 11-Oct-15 12:06pm    
They get together? You mean that 2 records sound at the same time or 1 record is playing just after the other one like one single record?

1 solution

Call the Close method as Zoltán said:
axWindowsMediaPlayer1.Close();

That should end with your problem.

Good Luck - CCB
 
Share this answer
 
Comments
Oğuzhan Kalsın 11-Oct-15 5:17am    
yea it solved the problem but now the records are getting together.how can i clear the previus one ?
ChrisCreateBoss 11-Oct-15 13:17pm    
They get together? You mean that 2 records sound at the same time or 1 record is playing just after the other one like one single record?
Oğuzhan Kalsın 11-Oct-15 15:20pm    
no it was like firstly the first one then the second one bla bla bla but i solved it already so thank you
ChrisCreateBoss 11-Oct-15 15:35pm    
Oh ok got ya. You are welcome. Glad to help you. - CCB

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900