1

I am using MediaElement for play video and its fails sometime without any exception.. just black window comes and Calling Play() (or Pause() then Play()) fails every time.

I have ScrubbingEnabled set to True so that I can show the first frame of the video to the user

Code:-

<MediaElement x:Name="VideoPlayer" LoadedBehavior="Manual" MediaOpened="VideoPlayer_MediaOpened" MediaEnded="VideoPlayer_MediaEnded" 
 MediaFailed="VideoPlayer_MediaFailed"  UnloadedBehavior="Manual" Stretch="Uniform" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
 SizeChanged="VideoPlayer_SizeChanged" SourceUpdated="VideoPlayer_SourceUpdated" ></MediaElement>

And after restart exe same video play perfectly.

is am doing any thing wrong or its .Net issue ?

Ankur Tripathi
  • 671
  • 9
  • 35
  • Please be more precise... what does "fail" mean, are any of the registered events called before it "fails"? – grek40 May 09 '17 at 12:00
  • just black window comes and Calling Play() (or Pause() then Play()) fails every time. did'nt get any event – Ankur Tripathi May 09 '17 at 12:08
  • What do you mean with "Play() fails"? Is the function returning and the program continues or is something else happening? – grek40 May 09 '17 at 12:16

1 Answers1

2

MediaElement uses EVR, which in turn uses Direct3D. EVR is a limited resource, which you are using an instance per MediaElement, and once in a while the playback hits the limit. Unfortunately, the problem is suppressed somewhere inside the API and no reasonable error reporting takes place.

You can estimate the number of playback instances using a tool referenced in this answer: Black video using multiple instances VMR 9 (there is EVR option there as well).

https://stackoverflow.com/a/23393963/5096993

Ankur Tripathi
  • 671
  • 9
  • 35