1

基于Linphone Windows 10 应用程序实现,我可以通过设置属性Linphone.Core.NativeVideoWindowId和两个控件NativePreviewVideoWindowId的相应Name:s来查看远程和本地视频。Windows.UI.Xaml.Controls.SwapChainPanel

在相应的Xamarin AndroidiOS应用程序中使用Linphone时,应使用哪些 UI 控件,以及应使用哪些控件属性在这些平台上定义和?NativeVideoWindowIdNativePreviewVideoWindowId

4

2 回答 2

1

我有类似的问题。

安卓:

videoView = new GL2JNIView(context);
surfaceView = new SurfaceView(context);

例如,通过自定义渲染器分配ViewRenderer<CameraPreview, Droid.Lib.CameraPreview>

IOS:

 var wrapper = (Xamarin.Forms.Platform.iOS.NativeViewWrapper)contentViewVideoParent.Content;
                var videoview = (UIView)wrapper.NativeView;

并分配IntPtr videoview.Handle给 linphone 视图。

于 2018-05-28T12:39:16.393 回答
0

我用你的答案解决了同样的问题,但我认为在这个例子中缺少一些代码(对于下一个人,有同样的问题),所以我发布了对我有用的代码。

对于 iOS:


AppDelegate.cs(iOS 项目)

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();
    LoadApplication(new App(IntPtr.Zero));
    View view = null;
    UIView iView = new UIView(new RectangleF(0,0,640,480));
    view = iView.ToView();
    ((App)App.Current).ViedoFrame().Content = view;
    NativeViewWrapper wrapper = (NativeViewWrapper)((App)App.Current).ViedoFrame().Content;
    UIView uiView = (UIView)wrapper.NativeView;
    ((App)App.Current).Core.NativePreviewWindowId = uiView.Handle;
    ((App)App.Current).Core.VideoDisplayEnabled = true;
    ((App)App.Current).Core.VideoPreviewEnabled = true;
    
    return base.FinishedLaunching(app, options);
}

App.cs(共享项目)

public partial class App : Application
{
    ...
    
    public Page MainPageContent;
    
    public App(IntPtr context)
    {
        InitializeComponent();
        MainPageContent = new MainPage();
        MainPage = new NavigationPage(MainPageContent);
    }
    
    public ContentView ViedoFrame()
    {
        return MainPageContent.FindByName<ContentView>("video_frame");
    }
    
    ...
}

MainPage.xaml(共享项目)

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Kiwi"
             x:Class="Project.Linphone"
             Title="KiwiDoorUni">
             
    <ContentPage.ToolbarItems>
        ...
    </ContentPage.ToolbarItems>
    
    <StackLayout>
        ...
        <ContentView x:Name="video_frame">
        <!-- leave blank, UIView will be inserted here -->
        </ContentView>
    </StackLayout>
</ContentPage>

对于安卓


我在 Linphone Xamarin 示例项目中使用了 BelledonneCommunications 的代码,它对我有用

示例项目可以在这里找到:

https://github.com/BelledonneCommunications/linphone-xamarin

检查文件:MainActivity.cs(android项目)

于 2020-12-28T18:04:48.383 回答