Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

is not a member of 'Object'.

Discussion in 'Editor & General Support' started by FrazZahid, Jul 10, 2014.

  1. FrazZahid

    FrazZahid

    Joined:
    Jun 10, 2014
    Posts:
    15
    Below is the code it works on .exe as well as in unity engine but when i start build it for android it shows following error
    Assets/MIC.js(37,24): BCE0019: 'Play' is not a member of 'Object'.
    Assets/MIC.js(27,24): BCE0019: 'clip' is not a member of 'Object'.





    import System.Collections.Generic;
    import System.Collections.ObjectModel;

    private var buttonWidth = 200;
    private var buttonHeight = 80;
    private var micIn : boolean = false;
    private var getAudioSource;

    private var deviceName : String;

    function Start() {
    if(Microphone.devices.Length < 1){
    Debug.Log("Microphone not Connected");
    }else{
    micIn = true;
    deviceName = Microphone.devices[0];
    }
    Debug.Log(deviceName);
    getAudioSource = this.GetComponent("AudioSource");
    }


    function Update(){}
    // Audio Recorder
    function registerAudio() {
    Debug.Log("Recording Audio");
    getAudioSource.clip = Microphone.Start(null, true, 20, 44100);

    }

    function stopRecording(){
    Debug.Log("Stop Recording");
    Microphone.End(deviceName);
    }

    function playAudio(){
    getAudioSource.Play();
    }

    function OnGUI(){

    if(micIn){
    if(!Microphone.IsRecording(deviceName)){
    if(GUI.Button(Rect ( 10, (buttonHeight)+10 , buttonWidth, buttonHeight), "Record")){
    registerAudio();
    }
    }else{
    if(GUI.Button(Rect ( 10, (buttonHeight)+10 , buttonWidth, buttonHeight), "Stop Recording")){
    stopRecording();
    }
    }

    if(GUI.Button(Rect ( 10, 2*(buttonHeight)+10 , buttonWidth, buttonHeight), "PlayAudio")){
    playAudio();
    }

    if(Microphone.IsRecording(deviceName)){
    GUI.Label(Rect(buttonWidth +50, 10, buttonWidth, buttonHeight), "Recording");
    }else{
    GUI.Label(Rect(buttonWidth +50, 10, buttonWidth, buttonHeight), "Not Recording");
    }
    }
    }
     
  2. Aurore

    Aurore

    Director of Real-Time Learning Unity Technologies

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    Please post in the correct section and use code tags
     
    FrazZahid likes this.
  3. FrazZahid

    FrazZahid

    Joined:
    Jun 10, 2014
    Posts:
    15
    where i have to post this?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276