Skip to content Skip to sidebar Skip to footer

Cannot Read Property Stop Of Undefined - When Calling A Static Method From Inside Class

For some reason, when I run this code, even without first calling the startRecording method it gives me this error right after the page has loaded. Uncaught TypeError: Cannot read

Solution 1:

You should declare Recorder reference in the scope of class, so that stop recording method can use it.

 public class RecorderClass
{
    static Recorder rec;
    public RecorderClass()
    {
    }

    public static void startRecording()
    {
        rec = new Recorder();
        rec.record();
    }

    public static void stopRecording()
    {
        rec.stop();// stop() of undefined
    }
}

Post a Comment for "Cannot Read Property Stop Of Undefined - When Calling A Static Method From Inside Class"