From e79efd28f8f3f539ca976733ff4209e372dcb5ed Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 25 Sep 2012 03:24:38 +0200 Subject: commands: more user-control whether a command shows OSD bars/messages The "no-osd" prefix was introduced earlier to disable OSD selectively based on the key binding. Extend this, and allow the user to force display of an OSD bar ("osd-bar"), OSD message ("osd-msg") or both ("osd-msg-bar"). This changes mainly how property setting functions behave. The default behavior is still the same. --- mplayer.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 13ce3c5ecc..ab78276a87 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1425,6 +1425,35 @@ static void sadd_osd_status(char *buffer, int len, struct MPContext *mpctx, } } +// OSD messages initated by seeking commands are added lazily with this +// function, because multiple successive seek commands can be coalesced. +static void add_seek_osd_messages(struct MPContext *mpctx) +{ + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) + set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) { + mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, + mpctx->opts.osd_duration); + msg->show_position = true; + } + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) { + char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx)); + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + "Chapter: %s", chapter); + talloc_free(chapter); + } + assert(mpctx->master_demuxer); + if ((mpctx->add_osd_seek_info & OSD_SEEK_INFO_EDITION) + && mpctx->master_demuxer) + { + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + "Playing edition %d of %d.", + mpctx->master_demuxer->edition + 1, + mpctx->master_demuxer->num_editions); + } + mpctx->add_osd_seek_info = 0; +} + /** * \brief Update the OSD message line. * @@ -1439,10 +1468,7 @@ static void update_osd_msg(struct MPContext *mpctx) struct MPOpts *opts = &mpctx->opts; struct osd_state *osd = mpctx->osd; - if (mpctx->add_osd_seek_info) { - set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); - mpctx->add_osd_seek_info = false; - } + add_seek_osd_messages(mpctx); // Look if we have a msg mp_osd_msg_t *msg = get_osd_msg(mpctx); @@ -1483,15 +1509,6 @@ static void update_osd_msg(struct MPContext *mpctx) } } -void mp_show_osd_progression(struct MPContext *mpctx) -{ - mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, - mpctx->opts.osd_duration); - msg->show_position = true; - - set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); -} - void reinit_audio_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; @@ -3677,6 +3694,8 @@ static void play_current_file(struct MPContext *mpctx) encode_lavc_discontinuity(mpctx->encode_lavc_ctx); #endif + mpctx->add_osd_seek_info &= OSD_SEEK_INFO_EDITION; + m_config_enter_file_local(mpctx->mconfig); load_per_protocol_config(mpctx->mconfig, mpctx->filename); -- cgit v1.2.3