Skip to content

Commit

Permalink
Fix margin on episode tile progress indicator. Fix flashing chapter a…
Browse files Browse the repository at this point in the history
…rt when offline.
  • Loading branch information
amugofjava committed Nov 4, 2021
1 parent 473c791 commit dc7093a
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 178 deletions.
2 changes: 1 addition & 1 deletion lib/bloc/podcast/audio_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AudioBloc extends Bloc {
await audioPlayerService.pause();
break;
case TransitionState.fastforward:
await audioPlayerService.fastforward();
await audioPlayerService.fastForward();
break;
case TransitionState.rewind:
await audioPlayerService.rewind();
Expand Down
2 changes: 1 addition & 1 deletion lib/services/audio/audio_player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class AudioPlayerService {
Future<void> rewind();

/// Fast forward the current episode by pre-set number of seconds.
Future<void> fastforward();
Future<void> fastForward();

/// Seek to the specified position within the current episode.
Future<void> seek({@required int position});
Expand Down
17 changes: 8 additions & 9 deletions lib/services/audio/mobile_audio_player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class MobileAudioPlayerService extends AudioPlayerService {
}

@override
Future<void> fastforward() => AudioService.fastForward();
Future<void> fastForward() => AudioService.fastForward();

@override
Future<void> rewind() => AudioService.rewind();
Expand Down Expand Up @@ -490,22 +490,21 @@ class MobileAudioPlayerService extends AudioPlayerService {
}
}

/// Calculate our current chapter based on playback position, and if it's different to
/// the currently stored chapter - update.
void _updateChapter(int seconds, int duration) {
if (_episode == null) {
log.fine('Warning. Attempting to update chapter information on a null _episode');
} else if (_episode.hasChapters && _episode.chaptersAreLoaded) {
final chapters = _episode.chapters;

// What is our current chapter?
_episode.currentChapter = null;

for (var x = 0; x < _episode.chapters.length; x++) {
final startTime = chapters[x].startTime;
final endTime = x == (_episode.chapters.length - 1) ? duration : chapters[x + 1].startTime;
for (var chapterPtr = 0; chapterPtr < _episode.chapters.length; chapterPtr++) {
final startTime = chapters[chapterPtr].startTime;
final endTime = chapterPtr == (_episode.chapters.length - 1) ? duration : chapters[chapterPtr + 1].startTime;

if (seconds >= startTime && seconds < endTime) {
if (chapters[x] != _episode.currentChapter) {
_episode.currentChapter = chapters[x];
if (chapters[chapterPtr] != _episode.currentChapter) {
_episode.currentChapter = chapters[chapterPtr];
_episodeEvent.sink.add(_episode);
break;
}
Expand Down
Loading

0 comments on commit dc7093a

Please sign in to comment.