Why does WPF MediaElement not work on secondary monitor? -


my application uses wpf mediaelement play video (mov files). works when playing on primary monitor freezes when window moved secondary monitor.

i have tried following without success:

  1. starting application on secondary monitor
  2. swapping primary & secondary monitors (problem transfers new secondary monitor)

when application window spans both monitors works correctly entirely within secondary monitor video freezes. once in state, moving application primary monitor doesn't (and loading new video doesn't either).

the monitors arranged co-ordinates positive (both monitors 1920x1080 , secondary monitor origin 1920,0).

has else seen problem and/or found fix?

edit

does use wpf mediaelement multiple monitors???

this still known issue in .net framework 4.0, ms described "the issue occurs when synchronization between wpf , underlying wmp control have resynchronize when display changes occur." happens h.264 codec video files.


here 3 workarounds.

1 . use software rendering window containing mediaelement control

private void window_loaded(object sender, routedeventargs e) {         var hwndsource = presentationsource.fromvisual(this) hwndsource;         if (hwndsource != null)         {             var hwndtarget = hwndsource.compositiontarget;             if (hwndtarget != null) hwndtarget.rendermode = rendermode.softwareonly;         } } 

however not utilizing gpu , graphics memory , slow down video playback.


2. overlap @ least 1 pixel onto primary display

for example, suppose primary screen in on left, , mediaelement fills entire window. in window's constructor, suppose rect bounds represents secondary monitor boundary, use

this.left = bounds.left - 1; this.width = bounds.width; this.top = bounds.top; this.height = bounds.height; 

so mediaelement has 1 pixel wide overlapped on primary monitor, , it's able play h.264 video files normally.


3. use mp4 codec other ms's media foundation codec

download tool "win7dsfiltertweaker" disable media foundation "mp4" playback. install mp4 codec, ffshow, example.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -