1

I can't achieve simple thing. I'm using MediaElement and I want to play my video not from the beginning, but from, let's say, position 5 sec.

Workflow:

LoadedBehavior <- Manual;
Source <- some_source;
Play();

Inside MediaOpened:

Position <- 5 sec

Problem: For the few moments I see the beginning of the video and then it switches to 5 sec. I know that if I want to control Position manually I need to use LoadedBehavior Manual, but how can I make the video be Paused immediately after loading?

Cœur
  • 37,241
  • 25
  • 195
  • 267
gs_vlad
  • 1,409
  • 4
  • 15
  • 29
  • as a workaround hide the media element initially, and show when it starts playing from the desired time – pushpraj Sep 24 '14 at 01:32
  • I have a fadeIn() method where I animate OpacityProprerty and VolumeProperty from 0 to 1. And I do that inside MediaOpened event handler AFTER I set desired position and I still notice the skip between positions. – gs_vlad Sep 24 '14 at 05:32
  • perhaps adjust a begin time of animation with few hundred ms to see if that helps. see if [this answer](http://stackoverflow.com/questions/1346886/show-first-frame-of-video-in-wpf-mediaelement?rq=1) helps too – pushpraj Sep 24 '14 at 06:05

1 Answers1

0

The way I have done it and works is this (_location & _position I want are passed into the containing method of course)

MediaE2.Source = _location;
MediaE2.Position = _position;
//MediaE2.Source = new Uri(@"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv", UriKind.Absolute);

MediaE2.Play();

Set the position first then play.

Jim

Jim
  • 201
  • 2
  • 12
  • No, I can't set Position before MediaOpened event fire, because media attributes are not defined yet. – gs_vlad Sep 24 '14 at 05:28
  • gs_vlad, Can you give us a little more info or code so we can try and help further. – Jim Sep 25 '14 at 04:06