locked
First few calls to MediaElement.Play() don't seem to work. [SOLUTION] RRS feed

  • Question

  • Note to moderator: I think this is going to affect other people.  If this is not the right place to post solutions, then let me know if there's a Wiki somehwere.

    I play a keyboard click sound in my WinRT app, using a MediaElement object.  At first, the first few click sounds (calls to MediaElement.Play()) weren't audible.  I had to set the MediaElement's RealTimePlayback property to TRUE to solve this.  My guess is that makes the MediaElement buffer the sound immediately rather than load it asynchronously as needed.

    Caveat: Use this for short sound effects!  I wouldn't use this for large files or it might really slow down the loading of your app.


    -- roschler

    Wednesday, February 5, 2014 4:24 PM

All replies

  • Isnt it better to you autoplay or listen to the currentchanged event?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, February 5, 2014 4:52 PM
  • The MediaElement was set to AutoPlay (set to TRUE).  That didn't help.  I'm not sure how binding anything to the CurrentChanged property would help, can you elaborate?  The problem isn't knowing when the sound has changed, it never does.  It's just that (assumption) calling the MediaElement.Play() method before it has buffered the sound leads to the sound being inaudible until the sound is buffered.  

    -- roschler


    • Edited by roschler Wednesday, February 5, 2014 5:08 PM
    Wednesday, February 5, 2014 5:08 PM