WPF MediaElement control plays in debug sessions, but not at runtime

I am developing and testing an MP4 viewer control that looks like the image below, a simple parts list view. Users select an item from the list and the movie can be played on the right. I am using a MediaElement

WPF 4.5.x stack control. When debugging, this control works nicely. Outside the debugger, the control MediaElement

does not play anything. Instead, when a method is called PlayerMediaElement.Play()

(in the code to manage the details), the program saturates one CPU core, with 50% of the usage being shown as system overhead:

enter image description here

Movie Control

The XAML for the MediaElement control looks like this:

                               <MediaElement 
                                Source="{Binding MovieFile}" 
                                Loaded="PlayerMediaElement_Loaded" 
                                x:Name="PlayerMediaElement" 
                                MediaOpened="Element_MediaOpened" 
                                ScrubbingEnabled="True" 
                                LoadedBehavior="Manual" UnloadedBehavior="Manual"
                                />

      

The bind points to a string containing the full path to the file. "C: \ MyMovies \ Movie.MP4", that kind of thing.

The code for the control with MediaElement

in it contains the code recommended by Microsoft for manual transport control; events and timers, etc. I don't understand why it doesn't work outside of debug sessions. Movies just don't play, and data context switching generally minimizes control MediaElement

.

What should I be looking for?

+3


source to share





All Articles