版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lf12345678910/article/details/59486746
// Implement this class for media players that use the AudioFlinger software mixer
class MediaPlayerInterface : public MediaPlayerBase
// Implement this class for media players that output audio directly to hardware
class MediaPlayerHWInterface : public MediaPlayerBase
NuPlayerDriver : public MediaPlayerInterface
通常我们的调用逻辑是,构造函数->setDataSource->SetVideoSurfaceTexture->prepare/prepareAsync->start->stop->reset->析构函数,按照实际需求还会调用pause、isPlaying、getDuration、getCurrentPosition、setLooping、seekTo等。
各个接口具体含义参考下表:
方法 | 说明 |
---|---|
setDataSource | 设置多媒体数据来源(位置) |
setVideoSurfaceTexture | 设置用SurfaceHolder来显示多媒体 |
prepare | 准备(同步) |
prepareAsync | 准备(异步) |
start | 开始播放 |
stop | 停止播放 |
reset | 重置MediaPlayer对象为刚刚创建的状态 |
getCurrentPosition | 得到当前播放位置 |
getDuration | 得到文件的时间 |
isPlaying | 是否正在播放 |
pause | 暂停 |
seekTo | 指定播放的位置(以毫秒为单位的时间) |
setLooping | 设置是否循环播放 |
MediaPlayer.cpp NullPlayer.cpp GenericSource.cpp
setDataSource setDataSourceAsync setDataSource
prepare prepareAsync prepareAsync--initFromDataSource--MediaExtractor::Create