mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 11:38:11 +08:00
mk_player api 增加seek和获取进度以相对开始时间的接口以适应按时间轴方式回放的需求
This commit is contained in:
@@ -80,6 +80,13 @@ API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause);
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
|
||||
|
||||
/**
|
||||
* 设置点播进度条
|
||||
* @param ctx 对象指针
|
||||
* @param seekPos 取值范围 相对于开始时间增量 单位秒
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_seektoByPos(mk_player ctx, int seekPos);
|
||||
|
||||
/**
|
||||
* 设置播放器开启播放结果回调函数
|
||||
* @param ctx 播放器指针
|
||||
@@ -155,10 +162,15 @@ API_EXPORT int API_CALL mk_player_audio_channel(mk_player ctx);
|
||||
API_EXPORT float API_CALL mk_player_duration(mk_player ctx);
|
||||
|
||||
/**
|
||||
* 获取点播播放进度,取值范围未 0.0~1.0
|
||||
* 获取点播播放进度,取值范围 0.0~1.0
|
||||
*/
|
||||
API_EXPORT float API_CALL mk_player_progress(mk_player ctx);
|
||||
|
||||
/**
|
||||
* 获取点播播放进度位置,取值范围 相对于开始时间增量 单位秒
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_player_progress_pos(mk_player ctx);
|
||||
|
||||
/**
|
||||
* 获取丢包率,rtsp时有效
|
||||
* @param ctx 对象指针
|
||||
|
||||
@@ -62,6 +62,16 @@ API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
API_EXPORT void API_CALL mk_player_seektoByPos(mk_player ctx, int seekPos)
|
||||
{
|
||||
MediaPlayer::Ptr& player = *((MediaPlayer::Ptr*)ctx);
|
||||
player->getPoller()->async([seekPos, player]() {
|
||||
//切换线程后再操作
|
||||
player->seekTo((uint32_t)seekPos);
|
||||
});
|
||||
}
|
||||
|
||||
static void mk_player_set_on_event(mk_player ctx, on_mk_play_event cb, void *user_data, int type) {
|
||||
assert(ctx && cb);
|
||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||
@@ -169,6 +179,14 @@ API_EXPORT float API_CALL mk_player_progress(mk_player ctx) {
|
||||
return player->getProgress();
|
||||
}
|
||||
|
||||
|
||||
API_EXPORT int API_CALL mk_player_progress_pos(mk_player ctx)
|
||||
{
|
||||
assert(ctx);
|
||||
MediaPlayer::Ptr& player = *((MediaPlayer::Ptr*)ctx);
|
||||
return player->getProgressPos();
|
||||
}
|
||||
|
||||
API_EXPORT float API_CALL mk_player_loss_rate(mk_player ctx, int track_type) {
|
||||
assert(ctx);
|
||||
MediaPlayer::Ptr &player = *((MediaPlayer::Ptr *)ctx);
|
||||
|
||||
Reference in New Issue
Block a user