Rate This Document
Findability
Accuracy
Completeness
Readability

Enabling or Muting the Audio Engine

Application Scenario

Enable or mute the audio engine.

Prerequisites

  • The instruction stream engine has been started.
  • The audio engine has been registered.

Development Process

  1. When the activity is started, call startAudio to enable the audio.
  2. When the activity is stopped, call stopAudio to mute the audio.

Encoding Instance

public class Activity implements NativeListener {
    public void onStart() {
        int ret = AudioTrackPlayer.startAudio();
        if (ret == AudioTrackPlayer.VMI_SUCCESS) {
            // The audio is successfully enabled.
        }
        if (ret == AudioTrackPlayer.VMI_AUDIO_ENGINE_CLIENT_START_FAIL) {
            // The audio fails to be enabled.
        }
    }
    public void onStop() {
        int ret = AudioTrackPlayer.stopAudio();
        if (ret == AudioTrackPlayer.VMI_SUCCESS) {
            // The audio is successfully muted.
        }
        if (ret == AudioTrackPlayer.VMI_AUDIO_ENGINE_CLIENT_STOP_FAIL) {
            // The audio fails to be muted.
        }
    }
}