melihercan / WebRTCme

A cross-platform framework for adding WebRTC support to .NET MAUI, Blazor, and Desktop applications by using a single unified .NET/C# API.
https://github.com/melihercan/WebRTCme
MIT License
226 stars 46 forks source link

Muting local audio and video streams #8

Open georgeinva2004 opened 2 years ago

georgeinva2004 commented 2 years ago

Your work on this is BRILLIANT!!!! Thank-you.

I'm trying to mute the local audio and video on my Xamarin app. Based on WebRTC documentation found elsewhere, this should work to mute and unmute during each invocation. The localAudioTrack.Enabled propery gets set properly in the debugger, but on the next invocation the Enabled property doesn't retain the setting. Am I doing it the wrong way?

`private void ToggleMute() {

var userMedia = await WebRTCme.CrossWebRtc.Current.Window().Navigator().MediaDevices.GetUserMedia(_constraints); var localAudioTrack = userMedia.GetAudioTracks()[0]; localAudioTrack.Enabled = !localAudioTrack.Enabled;

}`

georgeinva2004 commented 2 years ago

On the Blazor side, the above code gives a not implemented exception which I believe is happening in WebRTCme.Blazor.Custom.WebRtc.cs. It looks like it's the conditional compilation below. Is this really necessary for the Blazor implementation?

` internal class WebRtc : IWebRtc { public static IWebRtc Create() => new WebRtc();

    public void Dispose()
    {
    }

if NETSTANDARD

    public IWindow Window(IJSRuntime jsRuntime) => throw new NotImplementedException();

else

    public IWindow Window(IJSRuntime jsRuntime) => WebRTCme.Bindings.Blazor.Api.Window.Create(jsRuntime);

endif

}

`