mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 01:22:30 +00:00
core: Clean up OSD seek info logic
Clean up the code and make the behavior more consistent. Before bits of the OSD information were triggered in different places, and various property commands that affect playback position only showed the seek bar while the main seek command also triggered showing the percentage in OSD text. Now only the seek and chapter commands trigger all information and others nothing (which is consistent with most property behavior).
This commit is contained in:
parent
694c067e19
commit
0f590fce19
11
command.c
11
command.c
@ -2227,7 +2227,7 @@ static struct {
|
||||
/// set/adjust or toggle command
|
||||
int toggle;
|
||||
/// progressbar type
|
||||
int osd_progbar;
|
||||
int osd_progbar; // -1 is special value for seek indicators
|
||||
/// osd msg id if it must be shared
|
||||
int osd_id;
|
||||
/// osd msg template
|
||||
@ -2235,7 +2235,7 @@ static struct {
|
||||
} set_prop_cmd[] = {
|
||||
// general
|
||||
{ "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus },
|
||||
{ "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL },
|
||||
{ "chapter", MP_CMD_SEEK_CHAPTER, 0, -1, -1, NULL },
|
||||
{ "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL },
|
||||
{ "pause", MP_CMD_PAUSE, 0, 0, -1, NULL },
|
||||
// audio
|
||||
@ -2317,7 +2317,9 @@ static int set_property_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
if (r <= 0)
|
||||
return 1;
|
||||
|
||||
if (set_prop_cmd[i].osd_progbar) {
|
||||
if (set_prop_cmd[i].osd_progbar == -1)
|
||||
mpctx->add_osd_seek_info = true;
|
||||
else if (set_prop_cmd[i].osd_progbar) {
|
||||
if (prop->type == CONF_TYPE_INT) {
|
||||
if (mp_property_do(pname, M_PROPERTY_GET, &r, mpctx) > 0)
|
||||
set_osd_bar(mpctx, set_prop_cmd[i].osd_progbar,
|
||||
@ -2386,8 +2388,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
case MP_CMD_SEEK:{
|
||||
float v;
|
||||
int abs;
|
||||
if (sh_video)
|
||||
mpctx->osd_show_percentage = sh_video->fps;
|
||||
mpctx->add_osd_seek_info = true;
|
||||
v = cmd->args[0].v.f;
|
||||
abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
|
||||
if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */
|
||||
|
@ -54,7 +54,12 @@ typedef struct MPContext {
|
||||
struct mp_fifo *key_fifo;
|
||||
struct input_ctx *input;
|
||||
struct osd_state *osd;
|
||||
int osd_show_percentage;
|
||||
|
||||
bool add_osd_seek_info;
|
||||
// if nonzero, hide current OSD contents when GetTimerMS() reaches this
|
||||
unsigned int osd_show_percentage_until;
|
||||
unsigned int osd_visible;
|
||||
|
||||
int osd_function;
|
||||
const ao_functions_t *audio_out;
|
||||
struct play_tree *playtree;
|
||||
|
43
mplayer.c
43
mplayer.c
@ -201,9 +201,6 @@ int enqueue=0;
|
||||
|
||||
static int list_properties = 0;
|
||||
|
||||
// if nonzero, hide current OSD contents when GetTimerMS() reaches this
|
||||
unsigned int osd_visible;
|
||||
|
||||
int term_osd = 1;
|
||||
static char* term_osd_esc = "\x1b[A\r\x1b[K";
|
||||
static char* playing_msg = NULL;
|
||||
@ -211,7 +208,6 @@ static char* playing_msg = NULL;
|
||||
static double seek_to_sec;
|
||||
static off_t seek_to_byte=0;
|
||||
static off_t step_sec=0;
|
||||
static int loop_seek=0;
|
||||
|
||||
static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
|
||||
|
||||
@ -312,7 +308,6 @@ static char* rtc_device;
|
||||
|
||||
edl_record_ptr edl_records = NULL; ///< EDL entries memory area
|
||||
edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
|
||||
short edl_decision = 0; ///< 1 when an EDL operation has been made.
|
||||
FILE* edl_fd = NULL; ///< fd to write to when in -edlout mode.
|
||||
int use_filedir_conf;
|
||||
|
||||
@ -1408,16 +1403,18 @@ static mp_osd_msg_t* get_osd_msg(struct MPContext *mpctx)
|
||||
unsigned diff;
|
||||
char hidden_dec_done = 0;
|
||||
|
||||
if (osd_visible) {
|
||||
if (mpctx->osd_visible) {
|
||||
// 36000000 means max timed visibility is 1 hour into the future, if
|
||||
// the difference is greater assume it's wrapped around from below 0
|
||||
if (osd_visible - now > 36000000) {
|
||||
osd_visible = 0;
|
||||
if (mpctx->osd_visible - now > 36000000) {
|
||||
mpctx->osd_visible = 0;
|
||||
vo_osd_progbar_type = -1; // disable
|
||||
vo_osd_changed(OSDTYPE_PROGBAR);
|
||||
mpctx->osd_function = mpctx->paused ? OSD_PAUSE : OSD_PLAY;
|
||||
}
|
||||
}
|
||||
if (mpctx->osd_show_percentage_until - now > 36000000)
|
||||
mpctx->osd_show_percentage_until = 0;
|
||||
|
||||
if(!last_update) last_update = now;
|
||||
diff = now >= last_update ? now - last_update : 0;
|
||||
@ -1467,7 +1464,7 @@ void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,d
|
||||
return;
|
||||
|
||||
if(mpctx->sh_video) {
|
||||
osd_visible = (GetTimerMS() + 1000) | 1;
|
||||
mpctx->osd_visible = (GetTimerMS() + 1000) | 1;
|
||||
vo_osd_progbar_type = type;
|
||||
vo_osd_progbar_value = 256*(val-min)/(max-min);
|
||||
vo_osd_changed(OSDTYPE_PROGBAR);
|
||||
@ -1494,7 +1491,15 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||
mp_osd_msg_t *msg;
|
||||
struct osd_state *osd = mpctx->osd;
|
||||
char osd_text_timer[128];
|
||||
|
||||
|
||||
if (mpctx->add_osd_seek_info) {
|
||||
set_osd_bar(mpctx, 0, "Position", 0, 100,
|
||||
demuxer_get_percent_pos(mpctx->demuxer));
|
||||
if (mpctx->sh_video)
|
||||
mpctx->osd_show_percentage_until = (GetTimerMS() + 1000) | 1;
|
||||
mpctx->add_osd_seek_info = false;
|
||||
}
|
||||
|
||||
// Look if we have a msg
|
||||
if((msg = get_osd_msg(mpctx))) {
|
||||
if (strcmp(osd->osd_text, msg->msg)) {
|
||||
@ -1513,7 +1518,7 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||
char percentage_text[10];
|
||||
int pts = demuxer_get_current_time(mpctx->demuxer);
|
||||
|
||||
if (mpctx->osd_show_percentage)
|
||||
if (mpctx->osd_show_percentage_until)
|
||||
percentage = demuxer_get_percent_pos(mpctx->demuxer);
|
||||
|
||||
if (percentage >= 0)
|
||||
@ -1533,10 +1538,6 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||
} else
|
||||
osd_text_timer[0]=0;
|
||||
|
||||
// always decrement the percentage timer
|
||||
if(mpctx->osd_show_percentage)
|
||||
mpctx->osd_show_percentage--;
|
||||
|
||||
if (strcmp(osd->osd_text, osd_text_timer)) {
|
||||
strncpy(osd->osd_text, osd_text_timer, 63);
|
||||
vo_osd_changed(OSDTYPE_OSD);
|
||||
@ -2446,7 +2447,6 @@ static void edl_update(MPContext *mpctx)
|
||||
mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: start [%f], stop "
|
||||
"[%f], length [%f]\n", next_edl_record->start_sec,
|
||||
next_edl_record->stop_sec, next_edl_record->length_sec);
|
||||
edl_decision = 1;
|
||||
}
|
||||
else if (next_edl_record->action == EDL_MUTE) {
|
||||
mpctx->edl_muted = !mpctx->edl_muted;
|
||||
@ -3928,22 +3928,13 @@ if (step_sec > 0 && !mpctx->paused) {
|
||||
play_n_frames=play_n_frames_mf;
|
||||
mpctx->stop_play=0;
|
||||
mpctx->abs_seek_pos=SEEK_ABSOLUTE; mpctx->rel_seek_secs=seek_to_sec;
|
||||
loop_seek = 1;
|
||||
}
|
||||
|
||||
if(mpctx->rel_seek_secs || mpctx->abs_seek_pos){
|
||||
if (seek(mpctx, mpctx->rel_seek_secs, mpctx->abs_seek_pos) >= 0) {
|
||||
// Set OSD:
|
||||
if(!loop_seek){
|
||||
if( !edl_decision )
|
||||
set_osd_bar(mpctx, 0,"Position",0,100,demuxer_get_percent_pos(mpctx->demuxer));
|
||||
}
|
||||
}
|
||||
seek(mpctx, mpctx->rel_seek_secs, mpctx->abs_seek_pos);
|
||||
|
||||
mpctx->rel_seek_secs=0;
|
||||
mpctx->abs_seek_pos=0;
|
||||
loop_seek=0;
|
||||
edl_decision = 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GUI
|
||||
|
Loading…
Reference in New Issue
Block a user