How to enable headphone monitor?
Headphone monitor refers to headphone collection monitoring. After inserting headphones (ordinary headphones or Bluetooth headphones) into the device, you can hear the sound collected by the device's microphone from the local headphone side.
-
Before using the headphone monitor function, please ensure that you have integrated ZEGO Express SDK in the project and implemented basic real-time audio and video functions. For details, please refer to Quick Start - Integrate and Quick Start - Implementation Process.
-
After enabling headphone monitor, you need to connect headphones to experience this function.
Native Platform
Native platform mainly refers to Android, iOS, Windows, and Linux platforms.
You can call the enableHeadphoneMonitor interface of ZEGO Express SDK to enable the headphone monitor function, and call the setHeadphoneMonitorVolume interface to adjust the headphone monitor volume.
The example code for each platform is as follows:
- Android
// Java
// Enable headphone monitor function, default is false
engine.enableHeadphoneMonitor(true);
// Adjust headphone monitor volume, value range is 0 ~ 200, default is "60".
engine.setHeadphoneMonitorVolume(60);- iOS
// Objective-C
// Enable headphone monitor function, default is NO
[engine enableHeadphoneMonitor:YES];
// Adjust headphone monitor volume, value range is 0 ~ 200, default is "60".
[engine setHeadphoneMonitorVolume:60];- Windows
// Windows
// Enable headphone monitor function, default is false
engine->enableHeadphoneMonitor(true);
// Adjust headphone monitor volume, value range is 0 ~ 200, default is "60".
engine->setHeadphoneMonitorVolume(60);- Linux
// Linux
// Enable headphone monitor function, default is false
engine->enableHeadphoneMonitor(true);
// Adjust headphone monitor volume, value range is 0 ~ 200, default is "60".
engine->setHeadphoneMonitorVolume(60);Web Platform
After enabling preview or starting to publish stream, set the "muted" attribute of the <video> tag to "false" to enable the headphone monitor function. By setting the "volume" attribute value of the <video> tag, you can adjust the volume of the headphone monitor.
videoElement.muted = false;
// volume: 0 ~ 1
videoElement.volume = 0.8;The API links and related documentation references for each platform are as follows:
| Platform | API Link | Related Reference |
|---|---|---|
| Android | Headphone Monitor | |
| iOS | Headphone Monitor | |
| Windows | Headphone Monitor | |
| Linux | Headphone Monitor | |
| Web | Headphone Monitor |
