Hello. Due to circumstances, I had to implement MediaElement on the App.xaml page.
<Application.Resources> <MediaElement x:Key="GlobalPlayer" AudioCategory="BackgroundCapableMedia" AutoPlay="True" Visibility="Collapsed"/> </Application.Resources> From MainPage.xaml.cs, I can easily access it. But there is also the ProgressBar, which is specified in MainPage.xaml
<ProgressBar Visibility="Collapsed" Height="5" x:Name="PlayingProgressBar" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Maximum="{Binding Path=NaturalDuration.TimeSpan.TotalSeconds, Mode=TwoWay, ElementName=App.Player}" Value="{Binding Path=Position.TotalSeconds, Mode=TwoWay, ElementName=Player}" Grid.Row="3" Margin="0,0,60,0" ShowPaused="True" BorderBrush="{ThemeResource MediaButtonBackgroundThemeBrush}" Foreground="{ThemeResource MediaButtonPointerOverBackgroundThemeBrush}" AutomationProperties.AccessibilityView="Control"/> How to bind data between pages from this MediaElement for ProgressBar?
Update
The player itself.
<Application.Resources> <MediaElement x:Key="GlobalPlayer" Name="GlobalPlayer" AudioCategory="BackgroundCapableMedia" AutoPlay="True" Visibility="Collapsed" /> </Application.Resources> Привязка к нему из любой страницы. <ProgressBar x:Name="PlayingProgressBar" Height="10" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowPaused="True" BorderBrush="{ThemeResource MediaButtonBackgroundThemeBrush}" Maximum="{Binding NaturalDuration.TimeSpan.TotalSeconds, Mode=OneWay, Source={StaticResource GlobalPlayer}}" Value="{Binding Position.TotalSeconds, Mode=OneWay, Source={StaticResource GlobalPlayer}}"/>