KNGuide_Voice
INFO
This English reference is based on Directions SDK with UI 1.12.8-hotfix02 (as of 2026-07-24). For the latest version, see the Korean reference.
Provides voice guidance.
Example code — KNGuide_Voice
class KNGuide_VoiceConstructor
Example code — Initialization
// <init>
KNGuide_Voice(voiceCode: KNVoiceCode, voiceDist: KNVoiceDist, guideObj: Any?, data: List<ByteArray>)Properties
| Name | Description | Type |
|---|---|---|
duration | Voice length (unit: seconds) | var duration: Int |
voiceCode | Voice code | var voiceCode: KNVoiceCode |
voiceDist | Guidance reference distance code | var voiceDist: KNVoiceDist |
guideObj | Guidance object. Present when voiceCode is KNVoiceCode_Turn or KNVoiceCode_Safety ; otherwise returns null (see details below). | val guideObj: Any? |
data | List of guidance voice data | var data: List<ByteArray> |
Details of guideObj
KNVoiceCode_Turn:KNDirectionKNVoiceCode_Safety:KNSafetyKNVoiceCode_CheckingRouteChange,KNVoiceCode_RouteChanged,KNVoiceCode_RouteUnchanged,KNVoiceCode_OutOfRoute:NSString
Reasons for a route request:
- Route deviation:
DEVIATION - User-initiated rerouting:
USER - Rerouting due to GPS error:
GPS_ERROR - Waypoint added:
WAYPOINT_ADD - Waypoint deleted:
WAYPOINT_DEL
Methods
setVolume
Sets the voice volume.
fun setVolume(volume: Float): UnitParameters
| Name | Description |
|---|---|
volume | Voice volume (range: 0f–1f) |
setUsage
Sets the usage of the audio attributes when playing voice guidance. Uses the constants defined in the Android AudioAttributes class; the default value is AudioAttributes.USAGE_MEDIA.
fun setUsage(usage: Int)Example code
// Example
setUsage(AudioAttributes.USAGE_MEDIA)Parameters
| Name | Description |
|---|---|
usage | Audio usage |
getUsage
Gets the currently set audio usage. The return value is a constant defined in the Android AudioAttributes class (for example, AudioAttributes.USAGE_MEDIA), provided as an integer value.
Example code — getUsage
fun setUsage(usage: Int) {
kn_usage = usage
}
fun getUsage() = kn_usagesetContentType
Sets the audio content type when playing voice guidance. Uses the constants defined in the Android AudioAttributes class; the default value is AudioAttributes.CONTENT_TYPE_MUSIC.
fun setContentType(contentType: Int)Parameters
| Name | Description |
|---|---|
contentType | Audio content type |
getContentType
Gets the currently set audio content type. The return value is a constant defined in the Android AudioAttributes class (for example, AudioAttributes.CONTENT_TYPE_MUSIC), provided as an integer value.
Example code — getContentType
fun setContentType(contentType: Int) {
kn_contentType = contentType
}
fun getContentType() = kn_contentType