After Creating Package in Xamarin UWP, Video is Playing Only With Voice, I am Not able to see Video

Viewed 227

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.

I am using below Package

Plugin.MediaManager.Forms

This is My XAML page

<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 Page

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

2 Answers

Basically there is no way to initialize renderer for video in native code for xamrin.UWP, so we need to manually load render assembly in initialize it in App.xaml.cs of UWP platform

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

Most likely from the behavior you are describing (and looking at your code), it sounds like it's because the Video is not being run on the UI thread, and this causes the app to play the audio but not the video. So change it to the following:

Device.BeginInvokeOnMainThread(() => { CrossMediaManager.Current.Play(fileName); });
Related