You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @andersonvieiragomeslopes, since I got a request for this, I thought I would just show how Im doing it, and get some input from you, what you think about this approach. For Maui, everything works pretty much the same, except for attaching the video view to the "forms" layout.
Trying use the Microsoft.Maui.Controls.Compatibility.Platform.Android.LayoutExtensions.ToView didnt work for me, got a runtime error saying there was no viewhandler for this when I tried to add it to a contentview(which used to work fine in Xamarin).
publicclassAcsVideoRendererViewHandler:ViewHandler<AcsVideoRenderer,FrameLayout>{privateFrameLayout_frameLayout;publicAcsVideoRendererViewHandler():base(AcsVideoRendererViewHandler.AcsVideoRendererMapper,null){}publicstaticPropertyMapper<AcsVideoRenderer,AcsVideoRendererViewHandler>AcsVideoRendererMapper=new(){[nameof(AcsVideoRenderer.NativeVideoView)]=(handler,virtualView)=>handler.SetNativeVideoView(virtualView.NativeVideoView),};privatevoidSetNativeVideoView(objectvirtualViewNativeVideoView){if(virtualViewNativeVideoView==null){return;}if(virtualViewNativeVideoViewis not VideoStreamRendererViewvideoStreamRendererView){thrownewArgumentException("Invalid parameter","NativeVideoView");}_frameLayout.AddView(videoStreamRendererView);}protectedoverrideFrameLayoutCreatePlatformView(){_frameLayout=newFrameLayout(MauiApplication.Current);_frameLayout.SetForegroundGravity(GravityFlags.Fill);return_frameLayout;}}
In iOS like this:
publicclassAcsVideoRendererViewHandler:ViewHandler<AcsVideoRenderer,UIView>{privateUIView_uiView;privateACSVideoStreamRendererView?_currentRenderer;publicAcsVideoRendererViewHandler():base(AcsVideoRendererViewHandler.AcsVideoRendererMapper,null){}publicstaticPropertyMapper<AcsVideoRenderer,AcsVideoRendererViewHandler>AcsVideoRendererMapper=new(){[nameof(AcsVideoRenderer.NativeVideoView)]=(handler,virtualView)=>handler.SetNativeVideoView(virtualView.NativeVideoView),};privatevoidSetNativeVideoView(objectvirtualViewNativeVideoView){if(virtualViewNativeVideoView==null){return;}if(virtualViewNativeVideoViewis not ACSVideoStreamRendererViewvideoStreamRendererView){thrownewArgumentException("Invalid parameter","NativeVideoView");}if(_currentRenderer!=null){// If there was a previous view, remove it.// This typically happens when camera is switched._currentRenderer.RemoveFromSuperview();}_currentRenderer=videoStreamRendererView;_uiView.Add(videoStreamRendererView);}protectedoverrideUIViewCreatePlatformView(){_uiView=newUIView();return_uiView;}}
Changed all video eventhandlers to take object instead of view(this feels a bit hacky...)
privatevoidVideoCallManagerOnOnLocalVideoAdded(object?sender,objectvideoView){_logger.Debug("Got view with local video stream");MainThread.InvokeOnMainThreadAsync(()=>CallerStatusCard.ACSLocalVideoStreamContainerView.NativeVideoView=videoView);}
Appreciate any improvements or suggestions to this, otherwise it works, and should provide the missing piece of the puzzle for making the demo Maui compliant I think...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey @andersonvieiragomeslopes, since I got a request for this, I thought I would just show how Im doing it, and get some input from you, what you think about this approach. For Maui, everything works pretty much the same, except for attaching the video view to the "forms" layout.
Trying use the Microsoft.Maui.Controls.Compatibility.Platform.Android.LayoutExtensions.ToView didnt work for me, got a runtime error saying there was no viewhandler for this when I tried to add it to a contentview(which used to work fine in Xamarin).
Anyway, here is what I did:
And the viewmodel looks like this:
Appreciate any improvements or suggestions to this, otherwise it works, and should provide the missing piece of the puzzle for making the demo Maui compliant I think...
Beta Was this translation helpful? Give feedback.
All reactions