Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method setAudioEnabled in Android doesn't work? #6809

Open
huynguyen96419 opened this issue Nov 19, 2024 · 3 comments
Open

Method setAudioEnabled in Android doesn't work? #6809

huynguyen96419 opened this issue Nov 19, 2024 · 3 comments

Comments

@huynguyen96419
Copy link

huynguyen96419 commented Nov 19, 2024

Short description

I want to mute audio by using setAudioEnabled(false) but it's doesn't work. And how i mute audio in Android SDK?

Environment

  • Operating system and version: Android Kotlin

Steps to reproduce

  1. When i click a button i used setAudioEnabled(false)
  2. Audio didn't mute

Expected behavior

Audio mute when i click button mute

Ask your questions on Ant Media Github Discussions

@Composable
fun StartLiveStream(
    context: Context,
    viewModel: WatchEventViewModel,
    urlStream: String?,
    roomId: String?
) {
//    var webRTCClientTest: IWebRTCClient? = null
    val webRTCClientTest = remember {
        mutableStateOf<IWebRTCClient?>(null)
    }
    val isEnableSound by viewModel.isEnableSound.collectAsState()

    val surfaceView = remember {
        SurfaceViewRenderer(context).apply {
            holder.addCallback(object : SurfaceHolder.Callback {
                // TODO: DatDang - Update url live stream
                override fun surfaceCreated(holder: SurfaceHolder) {
                    Log.d("Datdang", "surfaceCreated:")
                    webRTCClientTest.value = IWebRTCClient.builder()
                        .setActivity(context as Activity?)
                        .addRemoteVideoRenderer(this@apply)
                        .setServerUrl(urlStream)
                        .build()
                    webRTCClientTest.value?.play(roomId)
                }

                override fun surfaceChanged(
                    holder: SurfaceHolder,
                    format: Int,
                    width: Int,
                    height: Int
                ) {


                }

                override fun surfaceDestroyed(holder: SurfaceHolder) {
                    [email protected]()
                }
            })
        }
    }
    // Apply audio setting whenever `isEnableSound` changes
    LaunchedEffect(isEnableSound) {
        webRTCClientTest.value?.setAudioEnabled(isEnableSound)
    }
    }

@lastpeony
Copy link
Contributor

lastpeony commented Nov 20, 2024

Hello,
What do you mean by mute audio?

To mute microphone of your local participant please use
toggleSendAudio

void toggleSendAudio(boolean enableAudio);

https://github.com/ant-media/WebRTC-Android-SDK/blob/82c093e124980d1e9e24233ddc07f0ac225c88aa/webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCClient.java#L357

To mute incoming audio of all remote participants, use
void toggleAudioOfAllParticipants(boolean enabled);

https://github.com/ant-media/WebRTC-Android-SDK/blob/82c093e124980d1e9e24233ddc07f0ac225c88aa/webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCClient.java#L319

Also please ensure that you are using the latest SDK version.

@burak-58
Copy link
Contributor

Hi @huynguyen96419,
Did you have a chance to try what @lastpeony suggested?

@huynguyen96419
Copy link
Author

Hello, What do you mean by mute audio?

To mute microphone of your local participant please use toggleSendAudio

void toggleSendAudio(boolean enableAudio);

https://github.com/ant-media/WebRTC-Android-SDK/blob/82c093e124980d1e9e24233ddc07f0ac225c88aa/webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCClient.java#L357

To mute incoming audio of all remote participants, use void toggleAudioOfAllParticipants(boolean enabled);

https://github.com/ant-media/WebRTC-Android-SDK/blob/82c093e124980d1e9e24233ddc07f0ac225c88aa/webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCClient.java#L319

Also please ensure that you are using the latest SDK version.

You misunderstood my question. What I mean is the audio of the media when playing. I saw that the iOS SDK has a method called enableAudioTrack, but the Android SDK does not have that method. So I had to fork the library and make changes there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants