在Xamarin UWP中创建软件包后,视频只能通过语音播放,我看不到视频 [英] After Creating Package in Xamarin UWP, Video is Playing Only With Voice, I am Not able to see Video

查看:53
本文介绍了在Xamarin UWP中创建软件包后,视频只能通过语音播放,我看不到视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本的MediaManager插件来播放视频.当我在调试模式下运行应用程序时,一切正常,但是当我为窗口创建一个程序包时,视频显示的不是声音,而是声音.

I am using MediaManager Plugin with latest version to play a video. everything works fine when i run application in debug mode, but when i create a package for window, video is not showing only voice is heard.

我正在使用以下Package

I am using below Package

Plugin.MediaManager.Forms

这是我的XAML页面

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Digi_Sign.Views.MediaScreen"
             xmlns:forms="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms"
             BackgroundColor="Black">
    <ContentPage.Content>
        <Grid x:Name="stkLayout" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" BackgroundColor="Black">
            <forms:VideoView VideoAspect="AspectFill"  x:Name="videoPlayer" ShowControls="False"  />
             </Grid>
    </ContentPage.Content>
</ContentPage>

CS页面

CrossMediaManager.Current.Play(fileName);

在包错误日志中未找到错误,因为我提到在调试模式下一切正常,但在发布模式下不工作

No Errors Found in package error log, as i mentioned everything works fine when it is debug mode, but not working in release mode

推荐答案

基本上,无法使用xamrin.UWP的本机代码初始化视频的渲染器,因此我们需要在初始化时手动加载渲染程序集UWP平台的App.xaml.cs

下面是我的代码,其中我在 OnLaunched()中加载了程序集文件,并替换了现有的 Xamarin.Forms.Forms.Init()

Below is my code where i have load assembly files inside OnLaunched() and replace existing Xamarin.Forms.Forms.Init()

  protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Windows.UI.Xaml.Controls.Frame rootFrame = Window.Current.Content as Windows.UI.Xaml.Controls.Frame;
            if (rootFrame == null)
            {

                rootFrame = new Windows.UI.Xaml.Controls.Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;

                List<Assembly> assembliesToAdd = new List<Assembly>();
                assembliesToAdd.Add(typeof(VideoViewRenderer).GetTypeInfo().Assembly);
                Xamarin.Forms.Forms.Init(e, assembliesToAdd);


                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }

            Window.Current.Activate();
        }

有关更多详细信息,请点击此处.您可以在其中找到更多说明.

for more details, here is the link. where you can find more explaination.

https://forums.xamarin.com/discussion/119451/crossmedia-works-in-debug-but-not-in-release-for-uwp-error-msg-about-onecore

这篇关于在Xamarin UWP中创建软件包后,视频只能通过语音播放,我看不到视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆