Question

I need to play [short looped video (mp4) without sound] and [mp3-file] simultaneously.

I tried to create 2 MediaElements: for audio and video, but WindowsPhone can play only one MediaElement in one time.

Do you know any tricks how to play video and audio simultaneously?

Maybe there are other ways to play mp3 or video (no MediaElement)?

SoundEffect can play only WAV-files, so this way is not for me, because all my files are MP3.

Thanks in advance.

Était-ce utile?

La solution 3

I solve my issue using MediaStreamSource!

  1. Create 2 Streams:
    • from mp3-file for audio
    • from mp4-file for video
  2. Create new class from MediaStreamSource
  3. override OpenMediaAsync() - return video-info from Stream with mp4, audio-info from Stream with mp3
  4. override GetSampleAsync(MediaType) - if MediaType is Video - return mp4-sample, else - return mp3 sample

It works!

Ps: Links for examples:

Autres conseils

As first way is to use MediaElement so keep it as it is.

Secondly, you have two options,

1) you can make use of MediaPlayer if your mp3 is stored locally i.e. stored in isolatedstorage/medialibrary

2) you can use BackgroundAudioPlayer if your mp3 is located at specific server.

Hope this Helps.

For using Xaudio2 you can look into this link, download sample.

One problem can be with the music files, I am unsure now that I think about it if mp3 will work. But you can play music in the background of everything with it. If you have trouble with the formatting, there is this link Windows Phone xaudio2 where I had the format problem, with wav files. But see if you can get it to work :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top