Windows Phone 7.1 - Media Element not playing

2019-08-31 04:48发布

Windows Phone 7.1/7.5/Mango app.

I have four different MediaElements on the page.

  • One is played upon Load of the page.

  • Rest 3 I Play() it upon leftMouseButtonClick on different image element on the page. I call Stop() in the MediaEnded event handler.

Issue: The last mediaElement in the top-down order won't play. So it's not the element itself bu the order of the element that is behaving weird.

I have read this where it talks about a single MediaElement which I don't understand.

Does anyone has any ideas on this?

Note: I don't have to play all sound at the same time. Only one sound at a time.

I found one reference that talks having single MediaElement only and dynamically set the Source in the code. I haven't tried it yet, will do soon.

2条回答
相关推荐>>
2楼-- · 2019-08-31 05:34

In my case, I get the error at the 6th media element. I try to put 14 Media Elements in a project (just to see what happens). You could also use SoundEffect from XNA if you really need to have a lot of sources playing at the same time or something

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-08-31 05:38

To confirm your last sentence, you can only have one MediaElement per page. You'll have to consider changing the source from the code-behind (or using data-binding) instead of having a MediaElement for each piece of audio. Having multiple MediaElements won't throw an error, but it will just override the behaviour of the previously added one (like you're experiencing).

To set the audio from the code-behind, you can use either the SetSource (which accepts a stream) method, or the Source property which reads a Uri.

查看更多
登录 后发表回答