Skip to content

Commit

Permalink
Add mute prop to android
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussefHenna committed Nov 11, 2024
1 parent f15a332 commit 2b6a332
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class ExpoMapboxNavigationModule : Module() {
Prop("mapStyle") { view: ExpoMapboxNavigationView, style: String? ->
view.setMapStyle(style)
}

Prop("mute") { view: ExpoMapboxNavigationView, isMuted: Boolean? ->
view.setIsMuted(isMuted)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,18 @@ class ExpoMapboxNavigationView(context: Context, appContext: AppContext) : ExpoV
update()
}

fun setIsMuted(isMutedProp: Boolean?){
if(isMutedProp != null){
isMuted = isMutedProp
voiceInstructionsPlayer.volume(SpeechVolume(if(isMuted) 0.0f else 1.0f))
soundButton.findViewById<ImageView>(com.mapbox.navigation.ui.components.R.id.buttonIcon).setImageResource(if(isMuted) R.drawable.icon_mute else R.drawable.icon_sound)
}
}

@com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
private fun update(){
voiceInstructionsPlayer = MapboxVoiceInstructionsPlayer(context, currentLocale.toLanguageTag())
voiceInstructionsPlayer.volume(SpeechVolume(if(isMuted) 0.0f else 1.0f)) // Initial volume based on current isMuted state
speechApi = MapboxSpeechApi(context, currentLocale.toLanguageTag())

if(currentMapStyle != null){
Expand Down
1 change: 1 addition & 0 deletions src/ExpoMapboxNavigation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type ExpoMapboxNavigationViewProps = {
routeProfile?: string;
routeExcludeList?: string[];
mapStyle?: string;
mute?: boolean;
onRouteProgressChanged?: (event: { nativeEvent: ProgressEvent }) => void;
onCancelNavigation?: () => void;
onWaypointArrival?: (event: {
Expand Down

0 comments on commit 2b6a332

Please sign in to comment.