How could you determine the media position when playing a video in Silverlight?
- The elements mePlayer.width and mePlayer.height retrieves the positions of the media in silver light.
- The source of the media player is set by mePlayer.Source , using the uri resource.
- The position property is available to expose the information.
- This property is of TimeSpan so care should be taken while calculating these values.
- Subproperty of TimeSpan is TotalSeconds that helps in converting the TimeSpan property into float value.
- The length of the media is determined with the Video.NaturalDuration.TimeSpan.TotalSeconds.
- The easiest way is to determine the position of the progress bar and then just add the relativePosition value:
Canvas.SetLeft(progressPointer, Canvas.GetLeft(progressBar) + relativePosition);
- Silverlight does not have a working timer component. But there is a neat workaround.