Bagikan melalui


SoundBank.GetCue Method

Gets a cue from the sound bank.

Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public Cue GetCue (
         string name
)

Parameters

  • name
    Friendly name of the cue to get.

Return Value

Cue object.

Exceptions

Exception type Condition
ArgumentNullException The name parameter is null.

Remarks

Each Cue instance that you retrieve is unique, even when retrieving multiple cues with the same name. This allows multiple instances of the same Cue to exist and play simultaneously.

The Cue instance that you retrieve using this method is valid only as long as it is in scope. If the Cue instance is allowed to go out of scope, such as in the case of the Cue being retrieved and played without otherwise being stored, the Cue is marked to be disposed by the garbage collector. This will result in the Cue stopping playback at an indeterminate time when the garbage collector disposes of the Cue. To prevent this behavior, store Cue objects to prevent them from falling out of scope. Alternatively, you can call PlayCue to play a cue immediately that will not fall out of scope.

See Also

Tasks

How to: Play a Sound
How to: Stop or Pause a Sound

Concepts

Audio Overview

Reference

SoundBank Class
SoundBank Members
Microsoft.Xna.Framework.Audio Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista