Changed to better performant video looping code

This commit is contained in:
Caeden Statia 2020-02-21 17:10:21 -08:00
parent 711deb50a8
commit 73ecc0590c
3 changed files with 8 additions and 14 deletions

View file

@ -127,7 +127,7 @@ namespace ModAssistant
if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri)
{
MainWindow.Instance.BackgroundVideo.Stop();
MainWindow.Instance.BackgroundVideoSource.Source = videoUri;
MainWindow.Instance.BackgroundVideo.Source = videoUri;
}
MainWindow.Instance.BackgroundVideo.Play();
}

View file

@ -16,19 +16,7 @@
<ImageBrush x:Name="BackgroundImage" Stretch="{DynamicResource BackgroundImageStretch}"/>
</Rectangle.Fill>
</Rectangle>
<MediaElement Visibility="Hidden" LoadedBehavior="Manual" Name="BackgroundVideo">
<MediaElement.Triggers>
<EventTrigger RoutedEvent="MediaElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Name="BackgroundVideoSource" Storyboard.TargetName="BackgroundVideo" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MediaElement.Triggers>
</MediaElement>
<MediaElement Visibility="Hidden" LoadedBehavior="Manual" Name="BackgroundVideo" MediaEnded="BackgroundVideo_MediaEnded"/>
<Image x:Name="SideImage" UseLayoutRounding="True" SnapsToDevicePixels="True" HorizontalAlignment="Left" VerticalAlignment="{DynamicResource SideImageYPosition}" Width="{Binding RelativeSource={RelativeSource Self}, Path=Source.PixelWidth}" Height="{Binding RelativeSource={RelativeSource Self}, Path=Source.PixelHeight}" Stretch="Fill"/>
<Grid Margin="10">
<Grid.RowDefinitions>

View file

@ -303,5 +303,11 @@ namespace ModAssistant
Mods.Instance.RefreshColumns();
}
}
private void BackgroundVideo_MediaEnded(object sender, RoutedEventArgs e)
{
BackgroundVideo.Position = TimeSpan.Zero;
BackgroundVideo.Play();
}
}
}