天天看點

Android遊戲之音頻類設計Android遊戲之音頻類設計

A. setVolumeControlStream(AudioManager.STREAM_MUSIC);

<a target="_blank" href="http://developer.android.com/training/managing-audio/volume-playback.html">http://developer.android.com/training/managing-audio/volume-playback.html</a>

public final void  setVolumeControlStream (int streamType)

Added in API level 1

Suggests an audio stream whose volume should be changed by the hardware volume controls.

The suggested audio stream will be tied to the window of this Activity. Volume requests which are received while the Activity is in the

foreground will affect this stream.

It is not guaranteed that the hardware volume controls will always change this stream's volume (for example, if a call is in progress, its

stream's volume may be changed instead). To reset back to the default, use USE_DEFAULT_STREAM_TYPE.

Parameters

streamType

The type of the audio stream whose volume should be changed by the hardware volume controls. 

int STREAM_MUSIC The audio stream for music playback 

B.getAssets ()

public final AssetManager  getAssets ()

Retrieve underlying AssetManager storage for these resources.

C.AssetManager

<a target="_blank" href="http://developer.android.com/reference/android/content/res/AssetManager.html">http://developer.android.com/reference/android/content/res/AssetManager.html</a>

D.AssetFileDescriptor

<a target="_blank" href="http://developer.android.com/reference/android/content/res/AssetFileDescriptor.html">http://developer.android.com/reference/android/content/res/AssetFileDescriptor.html</a>

E.SoundPool

<a target="_blank" href="http://developer.android.com/reference/android/media/SoundPool.html">http://developer.android.com/reference/android/media/SoundPool.html</a>

The SoundPool class manages and plays audio resources for applications.

A SoundPool is a collection of samples that can be loaded into memory from a resource inside the APK or from a file in the file system. The

SoundPool library uses the MediaPlayer service to decode the audio into a raw 16-bit PCM mono or stereo stream. This allows applications to

ship with compressed streams without having to suffer the CPU load and latency of decompressing during playback.

maxStreams

the maximum number of simultaneous streams for this SoundPool object

the audio stream type as described in AudioManager For example, game applications will normally use STREAM_MUSIC.

srcQuality

the sample-rate converter quality. Currently has no effect. Use 0 for the default.

Returns

a SoundPool object, or null if creation failed

F.MediaPlayer

<a target="_blank" href="http://developer.android.com/reference/android/media/MediaPlayer.html">http://developer.android.com/reference/android/media/MediaPlayer.html</a>

G.MediaPlayer.OnCompletionListener

<a target="_blank" href="http://developer.android.com/reference/android/media/MediaPlayer.OnCompletionListener.html">http://developer.android.com/reference/android/media/MediaPlayer.OnCompletionListener.html</a>

本文淺述了“beginning-android-games”書本的相關基礎知識和相關類的設計分析,

本篇中的類實作來自“beginning-android-games\ch07-gl-basics”

繼續閱讀