Q:

The name 'Microphone' does not exist in the current context unity

The name 'Microphone' does not exist in the current context. getting this error when opening an unity(version 5.6.0f3) project is visual studio 2017 in window 8.
[RequireComponent (typeof (AudioSource))]
public class SingleMicrophoneCapture : MonoBehaviour 
{
    //A boolean that flags whether there's a connected microphone
    private bool micConnected = false;

    //The maximum and minimum available recording frequencies
    private int minFreq;
    private int maxFreq;

    //A handle to the attached AudioSource
    public AudioSource goAudioSource;
    public AudioClip recordedAudioClip;
    [HideInInspector]
    public AudioClip myAudioClip;
    //public Text fileExist;
    bool startRecording = false;

    public Sprite[] recordingSprites;
    public int count =0;
    //int recordedFileCount =0;
    public bool isDefaultAudioPlaying = false;
    [SerializeField]
    public Sprite[] playSprites;
    public GameObject forwardButton;
    public GameObject backwardButton;
    public GameObject playButton;
    public GameObject replayButton;
    //Use this for initialization
    public AudioClip[] allAudioClips;
    public string storyName;
    float[] samples;
    public Dictionary<int,float> recordedClipDict;
    void Start() 
    {
            //ReplayButtonClicked ();
        //Check if there is at least one microphone connected

        recordedAudioClip= null;
        if(Microphone.devices.Length <= 0)

            {
            //Throw a warning message at the console if there isn't
            Debug.LogWarning("Microphone not connected!");
        }
        else //At least one microphone is present
        {
            //Set 'micConnected' to true
            micConnected = true;

            //Get the default microphone recording capabilities
            Microphone.GetDeviceCaps(null, out minFreq, out maxFreq);

            //According to the documentation, if minFreq and maxFreq are zero, the microphone supports any frequency...
            if(minFreq == 0 && maxFreq == 0)
            {
                //...meaning 44100 Hz can be used as the recording sampling rate
                maxFreq = 44100;
            }

            //Get the attached AudioSource component
            goAudioSource = this.GetComponent<AudioSource>();
          // mainAudioSource = Camera.main.GetComponent<AudioSource> ();
        }

    }

how to solve this.

A:

You are getting this error because you using a platform that do not support the Microphone API. One of the platforms that do not support the Microphone API is the WebGL. There might be other platforms other than WebGL without Microphone support.
Switch to a platform that supports the Microphone API from the Build Settings.
You can also use Unity's preprocessor directives to guard it and make sure that the Microphone API is not used when using platforms that do not support it or did not implement it.
#if !UNITY_WEBGL
//YOUR Microphone CODE HERE
#endif

If you really need Microphone in WebGL with Unity, make a plugin or use this one(Not free).

