diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-09-23 21:48:48 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-09-23 21:48:48 +0000 |
commit | 4b182ff652ee52647913a065801df12c99989173 (patch) | |
tree | e9b5693d12b1ed049220de74eeeae524df73dbff /mplayer.c | |
parent | 1b927153645d10acd173d6909f19acc27f728536 (diff) | |
download | mpv-4b182ff652ee52647913a065801df12c99989173.tar.bz2 mpv-4b182ff652ee52647913a065801df12c99989173.tar.xz |
Add support for displaying subtitles on the command-line when playing
audio-only files.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29712 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -1507,6 +1507,26 @@ void set_osd_bar(int type,const char* name,double min,double max,double val) { name,ROUND(100*(val-min)/(max-min))); } +/** + * \brief Display text subtitles on the OSD + */ +void set_osd_subtitle(subtitle *subs) { + int i; + vo_sub = subs; + vo_osd_changed(OSDTYPE_SUBTITLE); + if (!mpctx->sh_video) { + // reverse order, since newest set_osd_msg is displayed first + for (i = SUB_MAX_TEXT - 1; i >= 0; i--) { + if (!subs || i >= subs->lines || !subs->text[i]) + rm_osd_msg(OSD_MSG_SUB_BASE + i); + else { + // HACK: currently display time for each sub line except the last is set to 2 seconds. + int display_time = i == subs->lines - 1 ? 180000 : 2000; + set_osd_msg(OSD_MSG_SUB_BASE + i, 1, display_time, "%s", subs->text[i]); + } + } + } +} /** * \brief Update the OSD message line. @@ -2492,6 +2512,8 @@ static int seek(MPContext *mpctx, double amount, int style) mpctx->audio_out->reset(); // stop audio, throwing away buffered data mpctx->sh_audio->a_buffer_len = 0; mpctx->sh_audio->a_out_buffer_len = 0; + if (!mpctx->sh_video) + update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 1); } if (vo_vobsub && mpctx->sh_video) { @@ -3704,6 +3726,7 @@ if(!mpctx->sh_video) { if(end_at.type == END_AT_TIME && end_at.pos < a_pos) mpctx->eof = PT_NEXT_ENTRY; + update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 0); update_osd_msg(); } else { |