Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Onclick音效问题(空指针和MediaPlayer警告_Android_Audio_Nullpointerexception_Media Player - Fatal编程技术网

Android Onclick音效问题(空指针和MediaPlayer警告

Android Onclick音效问题(空指针和MediaPlayer警告,android,audio,nullpointerexception,media-player,Android,Audio,Nullpointerexception,Media Player,我已经创造了一个简单的四弦琴调谐器的市场,我认为缺乏一个视觉愉悦和非常简单的调谐器 无论如何,首先,通过开发人员控制台,我可以看到按钮Onclick事件处存在空指针异常。我无法重新创建此异常,但是已经报告了四次 第二,在使用应用程序时查看日志,我可以看到此警告 E/MP3Extractor(68): Unable to resync. Signalling end of stream. 这里的条目似乎是相同的 它是如何工作的。 通过使用单选按钮,用户可以选择播放单个音符或连续音符。我创建了一个

我已经创造了一个简单的四弦琴调谐器的市场,我认为缺乏一个视觉愉悦和非常简单的调谐器

无论如何,首先,通过开发人员控制台,我可以看到按钮Onclick事件处存在空指针异常。我无法重新创建此异常,但是已经报告了四次

第二,在使用应用程序时查看日志,我可以看到此警告

E/MP3Extractor(68): Unable to resync. Signalling end of stream.
这里的条目似乎是相同的

它是如何工作的。 通过使用单选按钮,用户可以选择播放单个音符或连续音符。我创建了一个名为StopMediaPlayer的子例程,它可以再次停止、重置和实例化MediaPlayer。之所以使用此功能,是因为我似乎永远无法停止连续播放,而只能暂停播放

警告和NullPointerException是否相关?是否有更有效/更好的方法停止MediaPlayer,这意味着我不必每次都重新实例化笔记

多谢各位

一个令人不快的恶作剧

Button gButton = (Button) findViewById(R.id.gButton);
    gButton.setOnClickListener(new OnClickListener() 
    {
        public void onClick(View v)
        {
            if (singleRadio.isChecked() == true)
            {
                StopMediaPLayer();
                gNote.setLooping(false);
                gNote.start();


            }
            else if (contRadio.isChecked() == true)
            {
                StopMediaPLayer();
                gNote.setLooping(true);
                gNote.start();
            }

        }
    });
停止媒体播放器子程序

public void StopMediaPLayer()
{
    Log.i("UkuleleTuner", "Stop Media Player");
    gNote.setLooping(false);
    cNote.setLooping(false);
    eNote.setLooping(false);
    aNote.setLooping(false);

    gNote.stop();
    cNote.stop();
    eNote.stop();
    aNote.stop();

    gNote.reset();
    cNote.reset();
    eNote.reset();
    aNote.reset();

    gNote = MediaPlayer.create(this, R.raw.g_note);
    cNote = MediaPlayer.create(this, R.raw.c_note);
    eNote = MediaPlayer.create(this, R.raw.e_note);
    aNote = MediaPlayer.create(this, R.raw.a_note);
}