Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions src/xstate/actors/audioPlayer/audioPlayerMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,33 @@ export const audioPlayerMachine =
'User either clicks on the pause button or presses the space key',
target: '#audioPlayer.VISIBLE.AUDIO_PLAYER_INITIATED.PAUSED.ACTIVE',
},
REPEAT_AYAH: {
actions: [
assign({
ayahNumber: (context, event: any) => event.ayahNumber,
verseDelay: (context, event: any) => event.verseDelay,
}),
'pauseAudio',
'setAudioPlayerCurrentTime',
],
description: 'Repeat the current ayah',
target: '#audioPlayer.VISIBLE.AUDIO_PLAYER_INITIATED.DELAYING',
},
REPEAT_AYAH: [
{
actions: [
assign({
ayahNumber: (context, event: any) => event.ayahNumber,
verseDelay: (context, event: any) => event.verseDelay,
}),
'pauseAudio',
'setAudioPlayerCurrentTime',
],
cond: 'hasVerseDelay',
description:
'Repeat the current ayah with a configurable delay between verses',
target: '#audioPlayer.VISIBLE.AUDIO_PLAYER_INITIATED.DELAYING',
},
{
actions: [
assign({
ayahNumber: (context, event: any) => event.ayahNumber,
}),
'setAudioPlayerCurrentTime',
],
description:
'Repeat the current ayah seamlessly without pausing the audio',
target: '#audioPlayer.VISIBLE.AUDIO_PLAYER_INITIATED.PLAYING.ACTIVE',
},
],
SEEKING: {
description:
'When the mouse or keyboard keys are clicked to jump forward/backward 5 or 10 seconds or when the user wants to navigate to a specific time.',
Expand Down Expand Up @@ -1075,6 +1090,9 @@ export const audioPlayerMachine =
return context.surah === event.surah && reciterId === context.audioData?.reciterId;
},
isRepeatActive: (context) => !!context.repeatActor,
hasVerseDelay: (context, event: any) => {
return event.verseDelay > 0;
},
isUsingCustomReciterId: (context, event) => !!event.reciterId,
isAudioAlmostEnded: (context) => {
const { currentTime } = context.audioPlayer;
Expand Down