开发者

Sound does not play the first time. Why?

开发者 https://www.devze.com 2023-02-03 08:14 出处:网络
Igave it a shot on WP7 forums @ MS and no one could help, so trying here. I cooked up a simple app,开发者_C百科 that has a button. Upon clicking, it plays a sound with the MediaElement control.When I

I gave it a shot on WP7 forums @ MS and no one could help, so trying here.

I cooked up a simple app,开发者_C百科 that has a button. Upon clicking, it plays a sound with the MediaElement control. When I click the button the first time, it does not play at all. The second and subsequent times, it plays the sound fine.

The first time around, the MediaOpened event of the MediaElement if fired off, but the MediaEnded never fires. The subsequent times, the events work as expected.

I posted a small project here documenting the issue.

http://www.angryhacker.com/toys/MediaElementTest.zip


It is probably a bug with Native Media Library and is caused by

MediaPlayer.GameHasControl

When app has been loaded you could call button_click(null,null) with volume 0.0 - just a guess.

Do you want to play a music whole game or just something short like this one? As a workaround use SoundEffect class.


To close out the question. Here are comments by a dev on the WP7 team.

0

精彩评论

暂无评论...
验证码 换一张
取 消