Skip to content

Commit

Permalink
0.13.5 Subtitle code getting messy
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Apr 25, 2021
1 parent 04a566b commit 93be1cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">A mobile video player tailored for Japanese language learners.</p>

<p align="center" style="margin:0"><b>Latest GitHub Release:<br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.13.4-beta">0.13.4-beta 🇯🇵 → 🇬🇧</a><br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.13.5-beta">0.13.5-beta 🇯🇵 → 🇬🇧</a><br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.5.3-enjp-beta">0.5.3-beta 🇬🇧 → 🇯🇵</a></b><br></p>
<div latest></div>

Expand Down
29 changes: 6 additions & 23 deletions lib/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class _VideoPlayerState extends State<VideoPlayer> {

if (index < internalSubs.length) {
getSubtitleWrapper().subtitleController.updateSubtitleContent(
content: internalSubs[index].readAsStringSync());
content: sanitizeSrtNewlines(internalSubs[index].readAsStringSync()));
print("SUBTITLES SWITCHED TO TRACK $index");
} else {
_subTitleController.updateSubtitleContent(content: "");
Expand All @@ -682,14 +682,13 @@ class _VideoPlayerState extends State<VideoPlayer> {

if (result != null) {
if (result.path.endsWith("srt")) {
getSubtitleWrapper()
.subtitleController
.updateSubtitleContent(content: result.readAsStringSync());
getSubtitleWrapper().subtitleController.updateSubtitleContent(
content: sanitizeSrtNewlines(result.readAsStringSync()));
print("SUBTITLES SWITCHED TO EXTERNAL SRT");
} else {
getSubtitleWrapper().subtitleController.updateSubtitleContent(
content:
(await extractExternalSubtitles(result)).readAsStringSync());
content: sanitizeSrtNewlines(
(await extractExternalSubtitles(result)).readAsStringSync()));
print("SUBTITLES SWITCHED TO EXTERNAL ASS");
}
}
Expand Down Expand Up @@ -1188,23 +1187,7 @@ class _VideoPlayerState extends State<VideoPlayer> {
_currentSubTrack,
);

List<String> split = unprocessed.split("\n ");

for (int i = 0; i < 10; i++) {
for (int i = 1; i < split.length; i++) {
String currentLine = split[i];
String previousLine = split[i - 1];

if (previousLine.contains("-->") && currentLine.trim().isEmpty) {
split.removeAt(i);
}
if (previousLine.contains("-->") && currentLine.trim().isEmpty) {
split.removeAt(i);
}
}
}

String subtitles = split.join("\n");
String subtitles = sanitizeVttNewlines(unprocessed);

_subTitleController.updateSubtitleContent(content: subtitles);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: jidoujisho
description: A mobile video player tailored for Japanese language learners.
publish_to: none

version: 0.13.4+10
version: 0.13.5+11

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit 93be1cb

Please sign in to comment.