Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

Code working on Android but not in UWP #1426

Open
@Milowsky

Description

@Milowsky

Description

The MediaElement and IndicatorView are working fine in the Android. But when you select the UWP in start up project. No video is playing. Also the IndicatorView is not scrolling.

I have this question on the StackOverflow, here is the link for reference. But someone said that this may be a bug in xamarin, so I decided to post this here.

  1. Select the UWP in Start-up Projects.
  2. Run the Source.
  3. No video playing and the indicator view does not automatically scroll even if enabled.

Expected Behavior

image

Actual Behavior

image

Basic Information

Here is the code for the Designer and the code behind.
Designer
`

    <BoxView>
        <BoxView.Background>
            <LinearGradientBrush StartPoint ="1,0" EndPoint = "1,1">
                <GradientStop Color ="Transparent" Offset="0"></GradientStop>
                <GradientStop Color ="#5D9FFF" Offset="0.48"></GradientStop>
                <GradientStop Color ="#6BBBFF" Offset="1.0"></GradientStop>
            </LinearGradientBrush>
        </BoxView.Background>
    </BoxView>

    <Grid HeightRequest="280" Margin="30,30,30,100"
          RowSpacing="40" VerticalOptions="End">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <CarouselView x:Name="cvOnBoarding" IndicatorView="LandingIndicator" IsScrollAnimated="True"
                      ItemsSource="{Binding OnBoardings}" HorizontalOptions="End"
                      Grid.Row="0" IsSwipeEnabled="True" HorizontalScrollBarVisibility="Never">
            <CarouselView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Spacing="10">
                        <Label Text="{Binding Caption}" TextColor="White" FontSize="24" FontAttributes="Bold"
                               WidthRequest="220" HeightRequest="150" HorizontalOptions="Start" LineBreakMode="WordWrap"></Label>
                        <Label Text="{Binding Heading}" TextColor="White" FontSize="16" FontAttributes="Bold"
                               WidthRequest="250" HeightRequest="150" HorizontalOptions="Start" LineBreakMode="WordWrap"></Label>
                    </StackLayout>
                </DataTemplate>
            </CarouselView.ItemTemplate>
        </CarouselView>

        <IndicatorView x:Name="LandingIndicator" Grid.Row="1" IndicatorsShape="Circle"
                       IndicatorColor="#B8B8B8" SelectedIndicatorColor="#E7305E" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>

        <StackLayout Grid.Row="2" VerticalOptions="Start" HorizontalOptions="End">
            <Grid>
                <Button Grid.Column="0" x:Name="btnSignup" Text="Sign Up" HeightRequest="80" WidthRequest="145"
                    BackgroundColor="#E7305E" TextColor="White" CornerRadius="25" FontAttributes="Bold"/>
                <Button Grid.Column="1" x:Name="btnLogin" Text="Login" HeightRequest="80" WidthRequest="145"
                    BackgroundColor="White" TextColor="#2E4159" CornerRadius="25" FontAttributes="Bold" Command="{Binding LoginCommand}"/>
            </Grid>
        </StackLayout>
    </Grid>
</Grid>

**App.cs**

          public App()
    {
        InitializeComponent();
        Device.SetFlags(new[] { "MediaElement_Experimental", "Brush_Experimental" });
        DependencyService.Register<MockDataStore>();
        MainPage = new NavigationPage(new IndexPage());
    }

Code Behind

public partial class IndexPage : ContentPage
{
    Timer tmrAnimator;
    public IndexPage()
    {
        InitializeComponent();
        NavigationPage.SetHasNavigationBar(this, false);
        this.BindingContext = new IndexViewModel();
        AnimateMe();
    }

    private void AnimateMe()
    {
        tmrAnimator = new Timer(5000) { AutoReset = true, Enabled = true };

        tmrAnimator.Elapsed += (s, e) =>
        {

            if (BgVideo.CurrentState != MediaElementState.Playing)
            {
                BgVideo.Play();
            }


            Device.BeginInvokeOnMainThread(() =>
            {
                if (cvOnBoarding.Position == 3)
                {
                    cvOnBoarding.Position = 0;
                }

                cvOnBoarding.Position += 1;
                LandingIndicator.Position = cvOnBoarding.Position;
                
            });
        };
    }
}`
  • Version with issue:
  • Last known good version:
  • IDE: VISUAL STUDIO 2019
  • Platform Target Frameworks:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages: XamarinForms 4.8
  • Affected Devices: Desktop

Workaround

Reproduction imagery

Reproduction Link

Metadata

Metadata

Assignees

No one assigned

    Labels

    UWPUWP platform issue.a/MediaElementbugSomething isn't working. Breaky break.s/unverifiedThis issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions