2012-06-09 18 views
6

私はWindows 8 Metro App(C#/ XAML): 同じサウンドエフェクトを2回トリガーして同時に再生する方法を教えてください。Windows 8 Metro App(C#/ XAML)で同時に2つのサウンドを再生する

2回目の再生は、最初の再生が開始する前に開始する必要があります。

関連の質問は以下のとおりです。

Playing two sounds simultaneously c#Play two sounds simultaneusly

私は私が何をしたいんXNAため、このクラスを見つけましたが、メトロの下では使用できません。 http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffectinstance.aspx

答えて

17

ただ、別のメディアを作成しますすべての効果音の要素。

(わからない私は毎回、ファイルを再配置する必要があります)

public async void PlayLaserSound() 
    { 
     var package = Windows.ApplicationModel.Package.Current; 
     var installedLocation = package.InstalledLocation; 
     var storageFile = await installedLocation.GetFileAsync("Assets\\Sounds\\lazer.mp3"); 
     if (storageFile != null) 
     { 
      var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read); 
      MediaElement snd = new MediaElement(); 
      snd.SetSource(stream, storageFile.ContentType); 
      snd.Play(); 
     } 
    } 
+0

この作業は、Windowsの携帯電話8上のでしょうか? –

関連する問題