Skip to content

Instantly share code, notes, and snippets.

@leesei
Last active May 17, 2022 06:34
Show Gist options
  • Save leesei/8f55aa571715dbd4512cf4221b25ce8d to your computer and use it in GitHub Desktop.
Save leesei/8f55aa571715dbd4512cf4221b25ce8d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const OfflineModeMachine = Machine({
initial: 'paused',
context: {
scale: 1
},
states: {
paused: {
on: {
PLAYPAUSE: 'playing',
SEEK: 'paused',
GALLERY_SEEK: 'gallery',
NEXT_FRAME: 'paused',
PREV_FRAME: 'paused',
FF: 'fffb',
FB: 'fffb',
}
},
gallery: {
// `gallery` is mostly equivalent to `paused`
// but with different UI behavior
on: {
PLAYPAUSE: 'playing',
SEEK: 'paused',
GALLERY_SEEK: 'gallery',
NEXT_FRAME: 'paused',
PREV_FRAME: 'paused',
FF: 'fffb',
FB: 'fffb'
}
},
playing: {
on: {
PLAYPAUSE: 'paused',
SEEK: 'playing',
GALLERY_SEEK: 'gallery',
NEXT_FRAME: 'paused',
PREV_FRAME: 'paused',
FF: 'fffb',
FB: 'fffb',
EOS: 'eos'
}
},
fffb: {
on: {
PLAYPAUSE: 'playing',
SEEK: 'playing',
GALLERY_SEEK: 'gallery',
NEXT_FRAME: 'paused',
PREV_FRAME: 'paused',
FF: 'fffb',
FB: 'fffb',
EOS: 'eos'
}
},
eos: {
// `eos` includes start and end of stream
// `eos` is mostly equivalent to `paused`
// a seek to start will be triggered when
// upon PLAYPAUSE in `eof`
on: {
PLAYPAUSE: 'playing',
SEEK: 'paused',
GALLERY_SEEK: 'gallery',
NEXT_FRAME: 'paused',
PREV_FRAME: 'paused',
FF: 'fffb',
FB: 'fffb',
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment