Skip to main content

Microsoft Silverlight

Answered Question slider control does not change position of vidio in mediaelement controlRSS Feed

(0)

skm.software@yahoo.com
skm.soft...

Member

Member

196 points

216 Posts

slider control does not change position of vidio in mediaelement control

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;

        }

 

Sachin Mukhija
"Please Mark as answer if answer is correct".

surbhiydv
surbhiydv

Participant

Participant

1134 points

218 Posts

Re: slider control does not change position of vidio in mediaelement control

Check this link for all your needs for mediaplayer

http://timheuer.com/blog/archive/2007/08/31/cheating-creating-silverlight-media-player.aspx

skm.software@yahoo.com
skm.soft...

Member

Member

196 points

216 Posts

Answered Question

Re: slider control does not change position of vidio in mediaelement control

Hi

I myself solve the problem by setting the starting position of slider in mediaopen event asprivate void MediaVidio_MediaOpened(object sender, RoutedEventArgs e)

{

timelineSlider.Maximum = MediaVidio.NaturalDuration.TimeSpan.TotalMilliseconds;

}

Sachin Mukhija
"Please Mark as answer if answer is correct".
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities