public class AsyncPlayer
extends Object
| java.lang.Object | |
| android.media.AsyncPlayer | |
播放一系列音频URI,但在另一个线程上完成所有艰苦工作,以便在准备或加载时不会阻塞调用线程。
Public constructors |
|
|---|---|
AsyncPlayer(String tag) 构造一个AsyncPlayer对象。 |
|
公共方法(Public methods) |
|
|---|---|
void |
play(Context context, Uri uri, boolean looping, int stream) 此方法在API级别23中已弃用。 |
void |
play(Context context, Uri uri, boolean looping, AudioAttributes attributes) 开始播放声音。 |
void |
stop() 停止以前播放的声音。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
AsyncPlayer (String tag)
构造一个AsyncPlayer对象。
| 参数(Parameters) | |
|---|---|
tag |
String: a string to use for debugging |
void play (Context context, Uri uri, boolean looping, int stream)
此方法在API级别23中已弃用。
改为使用play(Context, Uri, boolean, AudioAttributes)
开始播放声音。 它实际上将在未来某个时候开始播放。 这里没有关于延迟的保证。 在另一个音频文件播放完之前调用它会停止播放,然后开始播放。
| 参数(Parameters) | |
|---|---|
context |
Context: Your application's context. |
uri |
Uri: The URI to play. (see setDataSource(Context, Uri)) |
looping |
boolean: Whether the audio should loop forever. (see setLooping(boolean)) |
stream |
int: the AudioStream to use. (see setAudioStreamType(int)) |
void play (Context context, Uri uri, boolean looping, AudioAttributes attributes)
开始播放声音。 它实际上将在未来某个时候开始播放。 这里没有关于延迟的保证。 在另一个音频文件播放完之前调用它会停止播放,然后开始播放。
| 参数(Parameters) | |
|---|---|
context |
Context: the non-null application's context. |
uri |
Uri: the non-null URI to play. (see setDataSource(Context, Uri)) |
looping |
boolean: whether the audio should loop forever. (see setLooping(boolean)) |
attributes |
AudioAttributes: the non-null AudioAttributes to use. (see setAudioAttributes(AudioAttributes)) |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
|