MediaPlayer: fix subtitles

- Setting word wrapping and resizing the BTextView to the video size
  before adding the text moves the subtitles to where they are supposed
  to be, and breaks long lines that would be cut off.
- Show last subtitle entry: _IndexFor returns the index at which to
  insert a new subtitle for some start time, so when getting an existing
  one, we always need the previous index. Before the change we would do
  that after checking the time of the subtitle at the returned index,
  which for the times of the last one would be outside the list.
- Improve charset detection by using the whole file. Just the first line
  of subtitle text may be too short to be useful, and to get there we
  should have decoded the file first. The refactor also fixes not getting
  the last entry from the file.
- While not subtitle related, fix typo in aspect ratio menu shortcuts.

Fixes: 18151
Change-Id: I83fae735d31bce4616da9128a46be15763c30591
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7833
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Máximo Castañeda
2024-07-08 20:10:10 +00:00
committed by Adrien Destugues
parent 2813fd13ca
commit a5df3d5221
4 changed files with 47 additions and 50 deletions
+2 -4
View File
@@ -1872,11 +1872,9 @@ MainWin::_SetupVideoAspectItems(BMenu* menu)
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("4 : 3",
new BMessage(M_ASPECT_4_3), 2, B_SHIFT_KEY));
menu->AddItem(item = new BMenuItem("4 : 3", new BMessage(M_ASPECT_4_3), '2', B_SHIFT_KEY));
item->SetMarked(fWidthAspect == 4 && fHeightAspect == 3);
menu->AddItem(item = new BMenuItem("16 : 9",
new BMessage(M_ASPECT_16_9), 3, B_SHIFT_KEY));
menu->AddItem(item = new BMenuItem("16 : 9", new BMessage(M_ASPECT_16_9), '3', B_SHIFT_KEY));
item->SetMarked(fWidthAspect == 16 && fHeightAspect == 9);
menu->AddSeparatorItem();