XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] - MediaElement with IsVisible, not display the vídeo

Open gutosys opened this issue 4 years ago • 5 comments

Description

Steps to Reproduce

  1. Create an MediaPicker and get vídeo
  2. Set item to MediaElement
  3. If has IsVisible control, when has vídeo, the vídeo not appear.

Expected Behavior

  • Show the vídeo

Actual Behavior

  • Not show the vídeo

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Workaround

Reproduction imagery

Reproduction Link

gutosys avatar Jun 15 '21 13:06 gutosys

Sorry I'm not sure what you mean. What are you setting IsVisible to? Please fill out more details on the template. Is this on iOS, Android, UWP? All? Please share some relevant code and/or a reproduction project.

jfversluis avatar Jun 16 '21 12:06 jfversluis

Sorry I'm not sure what you mean. What are you setting IsVisible to? Please fill out more details on the template. Is this on iOS, Android, UWP? All? Please share some relevant code and/or a reproduction project.

I intend to show the video on the screen, only after recording the video without taking up space on the screen if it has not been recorded, so IsVisible, controlling the layout.

gutosys avatar Jun 16 '21 12:06 gutosys

If I understand you correctly what you expect is:

  • MediaElement.IsVisible == false, it doesn't take up any space
  • You start loading the video
  • If the loading is complete and you are ready to play it only then set IsVisible to true and it should show up

Is that correct? And that is not what is happening now?

Again; some code or a reproduction sample would be greatly appreciated

jfversluis avatar Jun 16 '21 13:06 jfversluis

If I understand you correctly what you expect is:

  • MediaElement.IsVisible == false, it doesn't take up any space
  • You start loading the video
  • If the loading is complete and you are ready to play it only then set IsVisible to true and it should show up

Is that correct? And that is not what is happening now?

Again; some code or a reproduction sample would be greatly appreciated

Exactly this !

The ViewModel:

  async Task TapVideo()
        {
            if (VideoPath != null)
            {
                await App.Current.MainPage.DisplayAlert("Número máximo de vídeos permitidos: 1", string.Empty, "OK");
                return;
            }

            if (MediaPicker.IsCaptureSupported)
            {
                var result = await MediaPicker.CaptureVideoAsync();

                if (result != null)
                {
                    IsVideo = true;

                    var stream = await result.OpenReadAsync();
                    VideoPath = result.FullPath;
                    fileResultList.Add(result);
                }
            }
        }

The View:

<StackLayout Margin="0,20,0,20" IsVisible="{Binding IsVideo}">
                   <Label
                       
                       Style="{StaticResource LabelTitle}"
                       Text="Vídeo" />
                   <xct:MediaElement
                       AutoPlay="False"
                       HeightRequest="100"
                       HorizontalOptions="Start"
                       Source="{Binding VideoPath}"
                       WidthRequest="300" />
               </StackLayout>

If I use IsVisible, in StackLayout, the vídeo not show anymore, if I use on MediaElement, The video not show anymore. If I remove de IsVisible, the vídeo shows up on the screen.

gutosys avatar Jun 16 '21 17:06 gutosys

@gutosys I have experienced the same issue. If the element containing the MediaElement is hidden at initialization, it will not show any video. My workaround at the moment is to let the element be visible at initialization and quickly hide it OnAppearing(). You may need some delay before hiding it so that the MediaElement will properly load the video.

One more thing I have tried is inside the element containing the MediaElement, I make a button and start the video on click and it also works.

BuiNhatQuang avatar Mar 01 '22 10:03 BuiNhatQuang