Skip to main content
Home Forums Silverlight Programming Programming with .NET - General slider control does not change position of vidio in mediaelement control
2 replies. Latest Post by skm.software@yahoo.com on October 21, 2008.
(0)
skm.soft...
Member
196 points
216 Posts
10-21-2008 2:54 AM |
Hi I am using mediaelement control and slider to change the position of vidio in mediaelement but changing silder position does not affect the vidio position here is the code<Grid x:Name="LayoutRoot" Background="White" > <Grid.ColumnDefinitions> <ColumnDefinition Width="500" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="302"></RowDefinition> <RowDefinition Height="50"></RowDefinition> </Grid.RowDefinitions> <MediaElement x:Name="MediaVidio" BufferingTime="00:00:00" MouseMove="MediaVidio_MouseMove" Source="http://localhost:3810/butterfly.wmv" AutoPlay="False" Width="502" Height="300" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left"></MediaElement> <Grid Grid.Row="1" Grid.Column="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="35" /> <ColumnDefinition Width="55" /> <ColumnDefinition Width="105" /> <ColumnDefinition Width="15" /> <ColumnDefinition Width="20" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions> <Image x:Name="imgPlay" MouseLeftButtonDown="imgPlay_MouseLeftButtonDown" Source="images/images.jpg" Grid.Row="0" Grid.Column="0" Height="28" Width="28" HorizontalAlignment="Right"></Image> <TextBlock x:Name="lblTime" Width="55" Height="30" Text="TimeSpan" Grid.Row="0" Grid.Column="1"></TextBlock> <Slider Name="timelineSlider" Margin="5" Grid.Row="0" Grid.Column="2" ValueChanged="SeekToMediaPosition" Width="70"/>
</Grid> </Grid>
and for code behind
private void SeekToMediaPosition(object sender, RoutedPropertyChangedEventArgs<double> e) { int SliderValue = (int)timelineSlider.Value; lblTime.Text = Convert.ToString(timelineSlider.Value); // Overloaded constructor takes the arguments days, hours, minutes, seconds, miniseconds. // Create a TimeSpan with miliseconds equal to the slider value. TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); MediaVidio.Position = ts;
}
surbhiydv
Participant
1134 points
218 Posts
10-21-2008 3:03 AM |
Check this link for all your needs for mediaplayer
http://timheuer.com/blog/archive/2007/08/31/cheating-creating-silverlight-media-player.aspx
10-21-2008 3:08 AM |
Hi
{
timelineSlider.Maximum = MediaVidio.NaturalDuration.TimeSpan.TotalMilliseconds;