3

I'm designing and testing an MP4 viewer control that looks like the image below, a simple list-details kind of layout. Users select an item from the list, and the movie can be played on the right. I'm using the MediaElement control from the WPF 4.5.x stack. At debug, this control works beautifully. Outside the debugger the MediaElement control does not play back anything. Instead, once the PlayerMediaElement.Play() method is called (in code-behind on the details control), the program saturates one CPU core, with 50% of the utilization depicted 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 binding points to a string containing the full path of the file. "C:\MyMovies\Movie.MP4", that kind of thing.

Code-behind for the control with the MediaElement in it contains the code recommended by Microsoft for manual transport control; events and timers, etc. What I can't understand is why it fails to work outside of debugging sessions. The movies simply don't play, and data context switching collapses the MediaElement control altogether.

What should I be looking for?

Rob Perkins
  • 3,088
  • 1
  • 30
  • 51

0 Answers0