locked
How to play a .mp4 video file with WPF (mediaelement) ? RRS feed

  • Question

  • I would like to play a .mp4 with WPF.
    Does anybody know how can I accomplish it?
    It can play wmv but when I try to play a .mp4 it doesn't show anything. It's strange because the Blend designer shows the first frame of the .mp4 video in the mediaelement.
    I can play the video with Windows Media Player...

    Waiting for an aswer...
    Tuesday, August 5, 2008 3:46 PM

Answers

  • I am succesfully playing h.264 and h.265 files on my Ultimate x64 machine within a MediaElement. It seems like it may be your codec configuration. It sounds like the DirectShow Filter isn't being used for the Media Player Element. You may want to try a new codec pack. I have tried the K-Light Codec pack with success with my application running in x86.

    When you install the Codec pack make sure you check the box that says something like - Make Windows Media Player the default Player and check the box - "play Quicktime and .mov files".
    Regards, Tom
    • Marked as answer by Hunsoul Wednesday, August 6, 2008 4:45 PM
    Wednesday, August 6, 2008 12:43 PM

All replies

  • Are you running the Application in x86 mode? Some codecs I noticed won't work in x64.
    Regards, Tom
    Tuesday, August 5, 2008 7:26 PM
  • Thank you for your prompt answer.

    I use Windows Vista x64 ultimate on my PC - so maybe the problem is what you mentioned but I don't understand the reason because I can play it with Windows Media Player on the same PC.

    Do you know any solution for this? Is it mean that the problem comes from a not suitable codec? Maybe I should try to find a newer one?

    What do you think?

    Thanks!
    Tuesday, August 5, 2008 7:42 PM
  • The Windows Media Player you are running is probably x86 as well, unless you downloaded the x64 version. You can see which one you are running by checking the path to the executable in the properties.


    You should be able to change the application you are building to run in x86 mode as well. To do this, go to Properties under the project your Main Application runs from and in the Build tab you should see "Platform target:" Change this to x86.

    That should solve your problem.
    Regards, Tom
    • Edited by Code4Fun2000 Tuesday, August 5, 2008 8:28 PM fixed
    Tuesday, August 5, 2008 7:45 PM
  • Thank you again.

    I tried it, unfortunately it still doesn't work.
    The video file is a "standard" H.265 Apple MP4.

    I didn't installed any codec pack to my Vista x64 but the Media Player can play the video.
    Anyway I tried it on a x86 XP and the situation was the same. The only difference was that on XP even the Media Player could play the video.

    The strange thing is - as I mentioned before - I can see the first frame in Blend.

    Do you have any additional ideas?
     I think it's a common request to play mp4 video on Windows.

    Thanks,
    Zsombor
    Wednesday, August 6, 2008 9:07 AM
  • I am succesfully playing h.264 and h.265 files on my Ultimate x64 machine within a MediaElement. It seems like it may be your codec configuration. It sounds like the DirectShow Filter isn't being used for the Media Player Element. You may want to try a new codec pack. I have tried the K-Light Codec pack with success with my application running in x86.

    When you install the Codec pack make sure you check the box that says something like - Make Windows Media Player the default Player and check the box - "play Quicktime and .mov files".
    Regards, Tom
    • Marked as answer by Hunsoul Wednesday, August 6, 2008 4:45 PM
    Wednesday, August 6, 2008 12:43 PM
  • Hi Tom,

    Thank you for answering again.

    So you've check it on your PC? Ohh thank you for your time!

    You should have right. I'll try to intall the K-Light Codec pack or the Vista Codec pack.
    But it strange that Media Player can play the files. Anyway I can't open the video file with drag&drop to media player - it doesn't support the extension of the video - but I can open the file with 'open with...' command.
    I don't like installing codec packs to my PC - this is why I like KMPlayer.
    It's sad that the premium Vista doesn't contains more and more codecs defaultly.
    I would like to rewrite one of my old applications - which should plays H.264 mp4 files - with WPF/.net. In the old version I used quicktime API to play those files now I planned to use a simle and nice MediaElement.
    Now it's hard to do that. I've to include a codec pack into the installer. That could cause problems.

    I tried to install 'ffdshow_beta5_rev2033_20080705_clsid.exe' the ffdshow package (I tried to find a smaller package than the K-Light Coded pack) but I doesn't help.

    Thank you again for your time!
    Bye,
    Zsombor

    Wednesday, August 6, 2008 4:44 PM
  • Tom,

    I installed K-Light Codec pack - standard edition to my Vista x64. Now I can play my .mp4 file with a simple double click and I can track in the player - but my WPF application still can't play the file. When I start playing the file, the icon of 'Haali MediaSplitter' shows up on the tray.

    Could you try it on your PC, please?

    I've uploaded it onto this FTP

    https://webftp.graphisoft.com/reupload.html?code=MBDMYJ1218043190


    Ther rar containd my binaries. The exe in the debug folder plays the .mp4 file and the exe in the release folder plays a .wmv file. There is no any differences between the two exe.

    I would really appreciate it if you could try it.

    Thanks,
    Zsombor

    Wednesday, August 6, 2008 5:26 PM
  • Can you start by just hosting the video file, I will see if it runs in my app. If you can, host it on http://www.mediafire.com/ that way i dont ahve to install any plugins.
    Regards, Tom
    Wednesday, August 6, 2008 5:30 PM
  • Tom,
    Thanks for the link. I didn't use it before.
    I uploaded the file again. Here is the link:
    http://www.mediafire.com/?wywljslwyy7

    Thank you in advance,
    Zsombor
    Thursday, August 7, 2008 12:59 PM
  • Tom,

    Could you check it please?

    Best,
    Zsombor
    Tuesday, August 12, 2008 4:34 PM
  • You can use my library (http://quicktimewpflib.codeplex.com/) It's use QuickTime COM and can play mp4 even over http from remote server. You need QuickTime on computer with WPF App.
    Wednesday, September 1, 2010 3:34 AM
  • Hi Alexei,

     

    Thank you for the information. I'll try it! (anyway I finally solved the original problem with a codec pack but our application install QuickTime so using quicktime would be better).

     

    I've two questions:

    - You mentioned that it support playing over http. Is it possible to play YouTube h264 videos from the youtube webserver? Currently I'm looking for solution for that with own playing control functionality - play, pause, step,... - without using a browser frame and flash player.

    - Does your library work with .net 3.5 or v4? (or older)

     

    Best Regards,

    Zsombor

     

    Wednesday, September 1, 2010 8:50 AM
  • My library works with .NET 4.0 (because it is support embedded interop types - i don't like when 4 dll's realize 1 function). I use it to demostrate ability of playing mp4 video from russian social network (vk.com).

     

    Main problem with youtube - getting direct download link. If you can found format of youtube link, that quick time accept it would work.

    But when I tried to do Open URL even in Quick Time media player (" http://v16.lscache4.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dXSFNST19FSkNNN19LTFND&algorithm=throttle-factor&itag=34&ipbits=0&burst=40&sver=3&expire=1283371200&key=yt1&signature=BE5A7A43B64742364FAA9FF4F330ABE6B7BD7435.53FBD5E5AC756E9BC4F028D6BD0A86D07AAA07BB&factor=1.25&id=f08d3528e7ee0f69") It doesn't accept it.

     

    P.S. You can also try http://wpfmediakit.codeplex.com. With K-Lite Codec Pack it is playing *.flv files

    Wednesday, September 1, 2010 1:36 PM