stop sound xna
posted on 08 May 2008 19:26 by xnanoob in Tutorialsสวัสดีค่า วันก่อนหาวิธิหยุดเสียงเพลง เพราะไม่เคยเล่นเพลงยาวๆ มาก่อนนะค่ะ
ก็เลยมาจดเอาไว้ เผื่อลืมนะค่ะ
โดยจะต้องทำการใช้ object จาก class cue ไม่รู้ออกเสียงว่าอะไรเหมือนกัน "cue" โดย คลาสนี้จะสามารถ stop หรือ pause และ resume การเล่นเสียงต่อได้เลยอะค่ะ
ซึ่งก่อนอื่นจะต้องใช้คำสั่ง SoundBank.GetCue เข้ามาก่อนนะค่ะ แล้วถึงจะทำการต่อได้
| Cue cue; // Get the cue and play it. cue = soundBank.GetCue("music"); cue.Play(); |
จบแระค่า บายค่ะ งุงิ งุงิ
ที่มาจาก เอกสารอ้างอิง http://msdn.microsoft.com/en-us/library/bb203880.aspx
To stop or pause a sound
- Create an AudioEngine, WaveBank, and SoundBank at game start.
- During game update, call the Update method of the AudioEngine to allow the audio engine to process audio data.
- Retrieve a cue you wish to play by calling SoundBank.GetCue. Store the cue value that is returned.
- Once you have played the cue by calling Cue.Play, you may choose to pause the cue by calling Cue.Pause, or stop the cue entirely by calling Cue.Stop.
- If you wish to resume a paused cue, you can simply call Cue.Resume.
- If you wish to play a stopped cue, you must reacquire the cue by calling SoundBank.GetCue.
Tags: cue, sound, xna, xnanoob5 Comments








#1 By xnapadawan (203.107.169.250) on 2008-05-09 13:48