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

  1. Create an AudioEngine, WaveBank, and SoundBank at game start.
  2. During game update, call the Update method of the AudioEngine to allow the audio engine to process audio data.
  3. Retrieve a cue you wish to play by calling SoundBank.GetCue. Store the cue value that is returned.
  4. 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.
  5. If you wish to resume a paused cue, you can simply call Cue.Resume.
  6. If you wish to play a stopped cue, you must reacquire the cue by calling SoundBank.GetCue.

Comment



smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

น่าจะอ่านว่าคิวครับ สะกดเหมือนลูกคิวบอลในสนุ้กเกอร์ คือลูกขาวอ่ะครับ

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

แล้วมีโฆษณาแทรกด้วย wink

#2 By book on 2008-05-09 15:30

#1 xnapadawan : ขอบคุณมากค่ะ

#3 By xnanoob on 2008-05-10 08:15

ขอบคุณทุกๆอย่างครับอืมคือว่าพี่ครับ
ผมอยากได้ข้อมูลของหนังสืออ่าครับ^^ว่าซื้อที่ไหนราคาเท่าไรอ่าครับ นี่เมล์ผมนะครับ namenap@hotmail.com

#4 By sangtawan on 2008-05-12 23:01

#4 sangtawan :หนังสือไรอะ ขอชื่อหนังสือด้วยนะค่ะ

#5 By xnanoob on 2008-05-12 23:33