I have tv series project and I am using mediaelement. But I need help for seek bar. How to add this? How to make seek bar slider like MediaPlayerLauncher?
I'm try some thinks like this:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement x:Name="player1" MediaOpened="player1_MediaOpened" CurrentStateChanged="player1_CurrentStateChanged" />
<ListBox x:Name="alternatifliste" FontSize="20" FontStyle="Italic" FontWeight="Bold" Foreground="White" Margin="677,98,10,153" SelectionChanged="alternatifliste_SelectionChanged" />
</Grid>
<Button x:Name="play" Content="play" HorizontalAlignment="Left" Margin="94,336,0,0" Grid.Row="1" VerticalAlignment="Top" Click="play_Click"/>
<Button x:Name="stop" Content="stop" HorizontalAlignment="Left" Margin="331,336,0,0" Grid.Row="1" VerticalAlignment="Top" Click="stop_Click"/>
<Slider Name="timelineSlider" Margin="0,68,0,244" Grid.Row="1" ValueChanged="timelineSlider_ValueChanged" />
</Grid>
My project:
İts code:
private void player1_MediaOpened(object sender, RoutedEventArgs e)
{
TimeSpan ts = player1.NaturalDuration.TimeSpan;
timelineSlider.Maximum = ts.TotalSeconds;
timelineSlider.SmallChange = 1;
timelineSlider.LargeChange = Math.Min(10, ts.Seconds / 10);
}
private void seekBar_DragCompleted(object sender, DragCompletedEventArgs e)
{
player1.Position = TimeSpan.FromSeconds(timelineSlider.Value);
}
private void timelineSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
player1.Position = TimeSpan.FromSeconds(timelineSlider.Value);
}
private void player1_CurrentStateChanged(object sender, RoutedEventArgs e)
{
//timelineSlider.Value = player1.Position.Seconds;
}
I want like this: