WEB开发网
开发学院手机开发Android 开发 Android多媒体框架初步分析 阅读

Android多媒体框架初步分析

 2010-05-27 03:42:00 来源:WEB开发网   
核心提示:int getVideoWidth()Returns the width of the video.boolean isPlaying()Checks whether the MediaPlayer is playing.void pause()Pauses playback.void prepare()Prepare

int getVideoWidth()

Returns the width of the video.

boolean isPlaying()

Checks whether the MediaPlayer is playing.

void pause()

Pauses playback.

void prepare()

Prepares the player for playback, synchronously.

void prepareAsync()

Prepares the player for playback, asynchronously.

void release()

Releases resources associated with this MediaPlayer object.

void reset()

Resets the MediaPlayer to its uninitialized state.

void seekTo(int msec)

Seeks to specified time position.

void setAudioStreamType(int streamtype)

Sets the audio stream type for this MediaPlayer.

void setDataSource(String path)

Sets the data source (file-path or http/rtsp URL) to use.

void setDisplay(SurfaceHolder sh)

Sets the SurfaceHolder to use for displaying the video portion of the media.

void setVolume(float leftVolume, float rightVolume)

Sets the volume on this player.

void start()

Starts or resumes playback.

void stop()

Stops playback after playback has been stopped or paused.

我们可以看出MediaPlayer类提供了一个多媒体播放器的基本操作,播放,暂停,停止,设置音量等等。

简单的例子:

Playing a File

MediaPlayer mp = new MediaPlayer();

mp.setDataSource(PATH_TO_FILE);

mp.prepare();

mp.start();

Playing a Raw Resource

MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);

mp.start();

Media Recorder

提供的基本接口如下:

Public Method:

void prepare()

Prepares the recorder to begin capturing and encoding data.

void release()

Releases resources associated with this MediaRecorder object.

上一页  1 2 3 4  下一页

Tags:Android 多媒体 框架

编辑录入:coldstar [复制链接] [打 印]
赞助商链接