Mercurial > mplayer.hg
comparison mplayer.c @ 29670:2e3751815a21
Add support for displaying subtitles on the command-line when playing
audio-only files.
author | reimar |
---|---|
date | Wed, 23 Sep 2009 21:48:48 +0000 |
parents | ecc719c6d7a9 |
children | f0b559a7c17b |
comparison
equal
deleted
inserted
replaced
29669:162402f4662b | 29670:2e3751815a21 |
---|---|
1505 | 1505 |
1506 set_osd_msg(OSD_MSG_BAR,1,osd_duration,"%s: %d %%", | 1506 set_osd_msg(OSD_MSG_BAR,1,osd_duration,"%s: %d %%", |
1507 name,ROUND(100*(val-min)/(max-min))); | 1507 name,ROUND(100*(val-min)/(max-min))); |
1508 } | 1508 } |
1509 | 1509 |
1510 /** | |
1511 * \brief Display text subtitles on the OSD | |
1512 */ | |
1513 void set_osd_subtitle(subtitle *subs) { | |
1514 int i; | |
1515 vo_sub = subs; | |
1516 vo_osd_changed(OSDTYPE_SUBTITLE); | |
1517 if (!mpctx->sh_video) { | |
1518 // reverse order, since newest set_osd_msg is displayed first | |
1519 for (i = SUB_MAX_TEXT - 1; i >= 0; i--) { | |
1520 if (!subs || i >= subs->lines || !subs->text[i]) | |
1521 rm_osd_msg(OSD_MSG_SUB_BASE + i); | |
1522 else { | |
1523 // HACK: currently display time for each sub line except the last is set to 2 seconds. | |
1524 int display_time = i == subs->lines - 1 ? 180000 : 2000; | |
1525 set_osd_msg(OSD_MSG_SUB_BASE + i, 1, display_time, "%s", subs->text[i]); | |
1526 } | |
1527 } | |
1528 } | |
1529 } | |
1510 | 1530 |
1511 /** | 1531 /** |
1512 * \brief Update the OSD message line. | 1532 * \brief Update the OSD message line. |
1513 * | 1533 * |
1514 * This function displays the current message on the vo OSD or on the term. | 1534 * This function displays the current message on the vo OSD or on the term. |
2490 if (mpctx->sh_audio) { | 2510 if (mpctx->sh_audio) { |
2491 current_module = "seek_audio_reset"; | 2511 current_module = "seek_audio_reset"; |
2492 mpctx->audio_out->reset(); // stop audio, throwing away buffered data | 2512 mpctx->audio_out->reset(); // stop audio, throwing away buffered data |
2493 mpctx->sh_audio->a_buffer_len = 0; | 2513 mpctx->sh_audio->a_buffer_len = 0; |
2494 mpctx->sh_audio->a_out_buffer_len = 0; | 2514 mpctx->sh_audio->a_out_buffer_len = 0; |
2515 if (!mpctx->sh_video) | |
2516 update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 1); | |
2495 } | 2517 } |
2496 | 2518 |
2497 if (vo_vobsub && mpctx->sh_video) { | 2519 if (vo_vobsub && mpctx->sh_video) { |
2498 current_module = "seek_vobsub_reset"; | 2520 current_module = "seek_vobsub_reset"; |
2499 vobsub_seek(vo_vobsub, mpctx->sh_video->pts); | 2521 vobsub_seek(vo_vobsub, mpctx->sh_video->pts); |
3702 if(!quiet) | 3724 if(!quiet) |
3703 print_status(a_pos, 0, 0); | 3725 print_status(a_pos, 0, 0); |
3704 | 3726 |
3705 if(end_at.type == END_AT_TIME && end_at.pos < a_pos) | 3727 if(end_at.type == END_AT_TIME && end_at.pos < a_pos) |
3706 mpctx->eof = PT_NEXT_ENTRY; | 3728 mpctx->eof = PT_NEXT_ENTRY; |
3729 update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 0); | |
3707 update_osd_msg(); | 3730 update_osd_msg(); |
3708 | 3731 |
3709 } else { | 3732 } else { |
3710 | 3733 |
3711 /*========================== PLAY VIDEO ============================*/ | 3734 /*========================== PLAY VIDEO ============================*/ |