AudioManager.isMusicActive() 始终返回 true

Aad*_*hya 5 android

我正在为统一游戏编写一些本机代码。我想知道游戏开始时设备是否正在播放某些内容。如果它正在播放某些内容,我想将游戏中的声音静音。

这是我在java类中的函数。我从统一方面创建上下文并将其传递给此函数。

public int CheckForDeviceSound(Context context)
{

      this.context = context;

      AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);

     if(manager.isMusicActive())

     {

        Log.i("My activity", "Music player active");

        IsPlaying = 1;

        return 1;

    }

    Log.i("My activity", "Music player not active");

    IsPlaying = 0;

    return 0;

}
Run Code Online (Sandbox Code Playgroud)

但 isMusicActive() 始终返回 true。我将所有游戏声音静音以进行测试,启动游戏但仍然得到真实的声音。我错过了什么吗?