2012-01-17 26 views
0

我使用soundeffect實例播放背景音樂。但我無法阻止聲音。我使用Common類來播放和停止聲音。在soundeffect實例中停止音樂的另一種方法

無論如何在使用soundeffectinstance進行播放時會停止播放音樂嗎?

+1

另外SoundEffects並不意味着用於播放背景音樂。 – 2012-01-17 11:31:28

回答

1

SoundEffect是火和忘記:

聲音在玩「射後不理」時尚與遊戲;因此,這些聲音的生命週期由框架管理。這些聲音 將播放一次,然後停止播放。它們不能循環或3D定位。 要循環播放聲音或應用3D效果,請調用CreateInstance而不是播放 或調用SoundEffectInstance.Play。

您需要創建SoundEffectInstance來代替,那麼您可以使用SoundEffectInstance.Stop()

+0

是的,SoundEffectInstance.Stop()不起作用。如果不創建SoundEffectInstance,它可以很好地工作。 StreamResourceInfo SoundFileInfo = App.GetResourceStream(new Uri(SoundFilePath,UriKind.Relative)); //從流中創建SoundEffect Sound = SoundEffect.FromStream(SoundFileInfo.Stream); – 2012-01-17 11:40:13