Adam
Adam

Reputation: 4780

Android VideoView Overlapping

I have two pages in Xamarin Forms using a custom renderer to display an Android VideoView on each page. The video on Page1 (nested inside of a RelativeLayout) plays successfully. When I navigate from Page1 to Page2 using Navigation.PushAsync(Page2); the VideoView from Page1 continues to overlap the video on Page2.

Is there a way to force the VideoView to respect the visibility of its parent view container?

Page1.xaml:

<?xml version="1.0" encoding="utf-8" ?>
        <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                     x:Class="MyVideoApp.Page1">
        <RelativeLayout>
            <MyVideoView x:Name="vidPlayer" Source="http://...."
                  RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                  RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}" />
          </RelativeLayout>
        </ContentPage>

Page2.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyVideoApp.Page2">

    <MyVideoView x:Name="vidPlayer" Source="http://...." />

</ContentPage>

Upvotes: 2

Views: 1127

Answers (1)

hvaughan3
hvaughan3

Reputation: 11105

The VideoView is a SurfaceView and SurfaceViews Z-order are determined before being attached to a window and cannot be changed afterwards. So you cannot have multiple SurfaceViews showing at the same time since the SurfaceView kind of shows through anything and everything.

You may need to try removing the VideoView completely and re-adding it later or, if all else fails, you could try moving the VideoView off of the screen.

Source

Upvotes: 1

Related Questions