locked
MediaElement is playing half of what WMP can RRS feed

  • Question

  • Hi
    I have media files ( avi, mpeg wmv ).
    Windows media player is rendering better and playing more of them.
    MediaElement plays some mpeg's and some it's not. Is there any way
    that I can force to ME to play at least what Media player is playing?

    Thanks
    PK
    Friday, September 28, 2007 4:47 PM

All replies

  • Are you getting any errors and can you describe a bit more about the rendering quality? In theory, WPF should have the same capability as WMP since it uses WMP OCX control under the hood for video playback.

    Saturday, September 29, 2007 12:14 AM
  • I am not getting any errors. Here is the complete and simple code:

     
    Code Block

       public partial class Window1 : System.Windows.Window
        {
            delegate void myDeleg();

            public Window1()
            {
                InitializeComponent();

                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new myDeleg(asd));
            }

            private void asd()
            {
                MediaElement me = new MediaElement();
                me.Source = new Uri(@"C:\myUsers\pkolodzi\movie2.mpg");

                VisualBrush vb = new VisualBrush(me);
                vb.Stretch = Stretch.Uniform;
                rect.Fill = vb;


            }

        }



    XAML:

    <Window x:Class="WindowsApplication2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WindowsApplication2" Height="300" Width="300"
        >
        <Grid x:Name="LayautRoot">
          <Rectangle Name="rect">
           
          </Rectangle>
        </Grid>
    </Window>





    'movie2.mpg' is a simple media file that is not displayed by my MediaElement. Instead i see just window as it's appearance is described by XAML. Media Player 11 is able to handle this media.

    Referring to the quality...
    When I play sample avi file, fps is very low. ( I observed this in 'avi' sample - wmv seem to work fine ). In media player everything is fine.
    Saturday, September 29, 2007 6:41 AM
  • I don't know if this has anything to do with your problem, but it seems like you are doing extra steps to create your media element.  Instead of creating it in code, can you create it directly in XAML?  For example:

     

    <Window x:Class="WindowsApplication2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WindowsApplication2" Height="300" Width="300"
        >
        <Grid x:Name="LayautRoot">
           <MediaElement Source="C:\myUsers\pkolodzi\movie2.mpg" Height="300" Width="300" />

        </Grid>
    </Window>

     

    Sunday, September 30, 2007 8:33 AM
  • Yoda would say : "The way you create MediaElement matters not" Wink. In fact it is true. Problem remains the same.
    I belive the way i did it in code is the shortest way.

    I am beginning to think if it would be easier to just create Video Class object from DirectX and play my media there.
    It would be harder to make it work with StoryBoard but i belive it's possible.
    Sunday, September 30, 2007 9:38 AM
  • I tired your code above and it does work. Can you make sure you have the latest video card driver installed? The low frame rate could be due to your video card or video driver is too out of date that WPF is rendering in software mode.

    Also, can you hookup MediaElement.MediaFailed event in your app? That will catch any media related errors you won't see otherwise.

    Thanks.

     

    Eddie.

    Tuesday, October 2, 2007 5:44 AM
  • Two years on, the MediaElement is still useless.  I have the latest drivers, the media failed event does not fire, but my video plays fine, sound wise, but the picture is really choppy.  What does my app do ? It plays videos, that's what it exists for.  It's not doing ANYTHING apart from trying to play a WMV smoothly.  I've had to use the wMP control in the past ( which creates all sorts of drawing issues in WPF ), and it's still the case that this control is close to useless, as far as I can see.

    Is there any fix for this ? Does MediaElement have a 'MakeThisThingActuallyWork' property ?

    (sorry for the attitude, to be frank, when I was an MVP and reported bugs in WPF, I was ignored, when I ask on these forums I don't get any replies, I'm starting to assume these forums are good for ranting, and not for trying to get actual help from anyone )


    Christian Graus
    Tuesday, March 17, 2009 11:35 PM
  • Alternatively, does anyone know of a wrapper for the windows media player control ? I have one, embedded in my app, but for some reason, when I use it in another application, it doesn't play video, only sound.
    Christian Graus
    Wednesday, March 18, 2009 5:14 AM
  • *bump*
    Christian Graus
    Wednesday, March 18, 2009 7:57 PM
  • *bump* I am still hoping that someone, somewhere can tell me a way that it's physically possible to write an application in WPF that includes video.  Right now I am bitterly disappointed, and quite confused.  I can play 19 thumbnail sized videos at once, but if I play a single larger format video file, in a control that's sized to be maybe 20% bigger than those thumbnails, just one video, it can't play it smoothly.  I am bitterly disappointed at this stage, I feel like our application should have been written in Flash.  Is Silverlight this bad ?
    '

    Christian Graus
    Friday, March 20, 2009 6:03 AM
  • Chiming in on lack of support regarding WPF video playback. I've been checking WPF forums for at least 18 months seeing the same problems with video playback but no answers.

    For full screen video playback WPresentationF ME is unusable. I already have a winform WMP ap, but I'd like to take advantage of the possibilities of WPF but the tearing issue makes it unusable.  Why can't the Media Element do its job?

    Will there be fixes in WPF 4? 

    Monday, March 22, 2010 11:01 PM
  • Hi Christian,

     

    Its a complex area.

     

    I work a lot with making mediaelement do more than what it does "out of the box".  All under winform WPF, not silverlight.

    most of what i do is via wpfmediakit.

     

    With the mpg file it may be worth going into graphedit and rendering the file to work out what codecs are being used to display it.

    if it doesnt render via graphedit on the target machine, then the codecs are missing, or even conflicting.  The combined community codec pack (CCCP) is pretty good for installing just about every codec for every format out there.

     

    With CCCP i haven't found a video file yet that wont play under mediaelement (except dvrms, wtv and DVD, for these i use my own filter graph via wpfmediakit).

     

    with wpfmediakit you can create a custom graph to force the filtergraph to use the codecs you want.

     

     

    The performance issues you have found when playing multiple videos is a show stopper.  i don't think WPF is going to give the performance to run a lot of videos.  if you ensure that the codec uses hardware acceleration, you may get part of the way to a solution.  With my project, around 8 videos just about maxes the CPU.

     

    I have a situation where videos won't play smoothly that is slightly different to yours.   i have a wpf grid that i extend onto all the monitors connected to the PC.  if i now add a mediaelement to the main screen and play it full screen then i get terrible stutters roughly every 40 seconds.

    To fix it i found that if i left a border around the mediaelement the stutter went away.  

     

    with the tearing issue that pedroabdu mentions it is only on XP machines that the tearing happens and from what i have read, there is no plan to fix it.

    if your target audience is going to be on XP, you can use the activex for windows media player.  There is no video tear this way, however you can not overlay WPF controls on top of the activeX.

     

     

    And lastly, even though it is said that mediaelement is just windows media player, i am not sure this is accurate.  there are plenty of comments on the web about files that run under WMP and not ME.

     

    I know this isn't really a "solution reply"  but hopefully it gives some insights for you.

     

    Cheers

    Anton

    Tuesday, March 23, 2010 1:14 PM