Awn Ali
Awn Ali

Reputation: 1379

How to Close Video in Windows 8 Metro App development

I have created a Popup of media player in which i am playing a MediaElement (i.e. Video). I have a close button as well on this Popup, which will close the media popup but problem is if i will click the Close button it will stop the MediaElement byt MediaElement.Stop(); and will hide the Popup as well. But continue to MediaElement Process in background As MediaElement.Stop() will just pause the Media and reset its point to 0.0

Can someone please help how i can remove this MediaElement from background, which is actually affecting my App Performance.

Upvotes: 0

Views: 285

Answers (2)

Usman
Usman

Reputation: 618

Try in following sequence:

  1. Call MediaElement.stop();
  2. Hide pop-up.
  3. Remove MediaElement from visual hierarchy, of popup.
  4. Dispose MediaElement.

Upvotes: 1

Anobik
Anobik

Reputation: 4899

the Best way you can work this out is by using a stream. open the audio using System.IO.Stream and when your popup closes then do (new System.IO.Stream()).Dispose();

Although using using keyword will automatically help you to dispose the stream but untill and unless a source is specified to the mediaelement then it will affect its performance . Try setting the source using setSource() method to null or the uri source to null. and then do a

(new System.IO.Stream()).Dispose();

Let me know if this works.

Upvotes: 0

Related Questions