设为首页 加入收藏

TOP

Android下的PVPlayer的实现
2014-11-24 03:03:22 来源: 作者: 【 】 浏览:1
Tags:Android PVPlayer 实现

class PVPlayer : public MediaPlayerInterface
{
public:
PVPlayer();
virtual ~PVPlayer();


virtual status_t initCheck(); //1
virtual status_t setDataSource(const char *url);//2
virtual status_t setDataSource(int fd, int64_t offset, int64_t length);//2
virtual status_t setVideoSurface(const sp& surface);//3
virtual status_t prepare();//4
virtual status_t prepareAsync();//5
virtual status_t start();//5
virtual status_t stop();//6
virtual status_t pause();//6
virtual bool isPlaying();
virtual status_t seekTo(int msec);
virtual status_t getCurrentPosition(int *msec);
virtual status_t getDuration(int *msec);
virtual status_t reset();
virtual status_t setLooping(int loop);
virtual player_type playerType() { return PV_PLAYER; }


// make available to PlayerDriver
void sendEvent(int msg, int ext1=0, int ext2=0) { MediaPlayerBase::sendEvent(msg, ext1, ext2); }


private:
static void do_nothing(status_t s, void *cookie, bool cancelled) { }
static void run_init(status_t s, void *cookie, bool cancelled);
static void run_set_video_surface(status_t s, void *cookie, bool cancelled);
static void run_set_audio_output(status_t s, void *cookie, bool cancelled);
static void run_prepare(status_t s, void *cookie, bool cancelled);


PlayerDriver* mPlayerDriver;
char * mDataSourcePath;
bool mIsDataSourceSet;
sp mSurface;
int mSharedFd;
status_t mInit;
int mDuration;


#ifdef MAX_OPENCORE_INSTANCES
static volatile int32_t sNumInstances;
#endif
};


1、 virtual status_t initCheck(); //这个函数会在我们创建播放器的时候调用,可以做一些基本的初始化工作,如下所示:


static sp createPlayer(player_type playerType, void* cookie,
notify_callback_f notifyFunc)
{
sp p;
switch (playerType) {
case PV_PLAYER:
LOGV(" create PVPlayer");
p = new PVPlayer();
break;
case SONIVOX_PLAYER:
LOGV(" create MidiFile");
p = new MidiFile();
break;
case VORBIS_PLAYER:
LOGV(" create VorbisPlayer");
p = new VorbisPlayer();
break;
}
if (p != NULL) {
if (p->initCheck() == NO_ERROR) {
p->setNotifyCallback(cookie, notifyFunc);
} else {
p.clear();
}
}
if (p == NULL) {
LOGE("Failed to create player object");
}
return p;
}


发现还有setNotifyCallback函数也会一起调用。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android Activity 回传数据 下一篇Android有趣的全透明效果

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)
·MySQL 索引 - 菜鸟教 (2025-12-24 10:18:06)
·Shell 基本运算符 - (2025-12-24 09:52:56)
·Shell 函数 | 菜鸟教 (2025-12-24 09:52:54)