Skip to content

Commit

Permalink
Fix anime player subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
kodjodevf committed Oct 9, 2023
1 parent 9d0a2c8 commit 0e7ffbc
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/modules/anime/anime_player_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
}
if (_firstVid.subtitles!.isNotEmpty) {
if (_initSubtitle) {
_player.setSubtitleTrack(_subtitle.value!);
try {
_player.setSubtitleTrack(_subtitle.value!);
} catch (_) {}
_initSubtitle = false;
}
}
Expand Down Expand Up @@ -243,11 +245,7 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
if (widget.videos.isNotEmpty && !widget.isLocal) {
for (var video in widget.videos) {
videoQuality.add(VideoPrefs(
videoTrack: VideoTrack(
video.url,
video.quality,
video.quality,
),
videoTrack: VideoTrack(video.url, video.quality, video.quality),
headers: video.headers,
isLocal: false));
}
Expand Down Expand Up @@ -291,10 +289,12 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
),
Icon(
Icons.check,
color: "${_video.value!.videoTrack!.id}${_video.value!.videoTrack!.title}" ==
"${quality.videoTrack!.id}${quality.videoTrack!.title}"
color: widget.isLocal
? Theme.of(context).iconTheme.color
: Colors.transparent,
: _video.value!.videoTrack!.title ==
quality.videoTrack!.title
? Theme.of(context).iconTheme.color
: Colors.transparent,
),
],
),
Expand All @@ -318,7 +318,10 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
_currentPosition != Duration.zero) {
await _player.stream.buffer.first;
_player.seek(_currentPosition);
_player.setSubtitleTrack(_subtitle.value!);
try {
_player.setSubtitleTrack(_subtitle.value!);
} catch (_) {}

_seekToCurrentPosition = false;
} else {
_currentPosition = position;
Expand Down Expand Up @@ -385,7 +388,9 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
.map((sub) => CupertinoActionSheetAction(
onPressed: () {
Navigator.maybePop(_);
_player.setSubtitleTrack(sub.subtitle!);
try {
_player.setSubtitleTrack(_subtitle.value!);
} catch (_) {}
if (!widget.isLocal) _subtitle.value = sub.subtitle;
},
child: Row(
Expand Down

0 comments on commit 0e7ffbc

Please sign in to comment.