c# - Windows Phone MediaElement -


I am creating an app using C # and XAM where I have 20 pages in some pages of each page And when I tap on it some dialogs should pop up. So I have taken a media idea and made it universally:

App.xaml:

  & lt; MediaElement x: Key = "StorySound" Volume = "1" Autoplay = "True" />   

App.xaml.cs:

  Get Public Static Media Assemble SourceSound {Current Return. Resources ["StorySound"] as MediaAliment; }}   

And on the tap event I wrote this code on every page:

  app Storysoud Source = New Uri ("/ Voice / Dialog /" + TextBox.text + ". Mp3, UricKind.Relative); App.StorySound.MediaOpened + = StorySound_MediaOpened; Zero StorySoundmediaopenad (Object Sender, Routing and EgEnges E) {App StorySound .play ();}   

When I navigate to the third page using the next page, then I do not play sound on more than 2 pages, on which I have not created any drama , But when I close the app and go straight to the The third page plays the role of sound. I have also tested using the message box to reflect the current state of mediacellation that I have found that the current situation is "open" and sound plays on the first two pages but the third page But the current situation is "closed" so the sound does not play. There is a memory problem while playing sound while using MediaAlment. Can not use the soundfifed because all my sound files are MP3 and if I use sound effects then I have to convert these sounds to .wav My app size will increase because I have more than 50 sound files .

If you understand correctly you can change the global StorySound You are hooking up on MediaOPend -event to -object, but you never open it. I give you this suggestion:

  • Use a local MediaElement on each page that you start (and probably close), or
  • Make sure that when you navigate, you remove all events on StorySound (so that each page is the only "user" of this global resource).

    I'm sure this should be better than MP3 in your app; You do not need to convert them to wav.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -