Skip to content

Instantly share code, notes, and snippets.

@Zenwolf
Last active November 20, 2019 17:03
Show Gist options
  • Save Zenwolf/6eec44c1d4bcadc9f94b073223912cc8 to your computer and use it in GitHub Desktop.
Save Zenwolf/6eec44c1d4bcadc9f94b073223912cc8 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 playbackMachine = Machine({
key: 'playback',
initial: 'initializing',
states: {
initializing: {
on: {
ready: 'paused'
},
onEntry: 'initializingCallback'
},
playing: {
initial: 'playing',
states: {
playing: {
on: {
stall: 'stalled',
buffer: 'buffering'
},
onEntry: 'playingCallback'
},
buffering: {
on: {
stall: 'stalled',
finish: 'playing'
},
onEntry: 'bufferingCallback'
},
stalled: {
on: {
buffer: 'buffering',
finish: 'playing'
},
onEntry: 'stalledCallback'
}
},
on: {
close: 'closed',
end: 'ended',
error: 'error',
pause: 'paused'
}
},
paused: {
on: {
close: 'closed',
error: 'error',
play: 'playing',
timeout: 'timedout'
},
onEntry: 'pausedCallback'
},
ended: {
on: {
close: 'closed',
play: 'playing'
},
onEntry: 'endedCallback'
},
closed: {
type: 'final',
onEntry: 'closedCallback'
},
timedout: {
type: 'final',
onEntry: 'timedoutCallback'
},
error: {
type: 'final',
onEntry: 'errorCallback'
}
}
},
{
actions: {
bufferingCallback: () => 'handleBuffering',
closedCallback: () => 'handleClosed',
endedCallback: () => 'handleEnded',
errorCallback: () => 'handleError',
initializingCallback: () => 'handleInitializing',
pausedCallback: () => 'handlePaused',
playingCallback: () => 'handlePlaying',
stalledCallback: () => 'handleStalled',
timedoutCallback: () => 'handleTimedout'
}
});
// const playerUIMachine = Machine(
// {
// initial: 'active',
// states: {
// active: {
// on: {
// inactivity: 'inactive',
// interaction: 'active'
// },
// onEntry: ['activeCallback']
// },
// inactive: {
// on: {
// interaction: 'active',
// longwait: 'passive'
// },
// onEntry: ['inactiveCallback']
// },
// passive: {
// on: {
// interaction: 'active'
// },
// onEntry: ['passiveCallback']
// }
// }
// },
// {
// actions: {
// activeCallback: () => 'handleActive',
// inactiveCallback: () => 'handleInactive',
// passiveCallback: () => 'handlePassive'
// }
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment