Last active
February 6, 2020 15:32
-
-
Save CAWeissen/3c42cbb6cd7d1e2bea346f5ee825053b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const videoMachine = Machine({ | |
id: 'video', | |
initial: 'loading', | |
context: { | |
video: null, | |
duration: 0, | |
elapsed: 0 | |
}, | |
states: { | |
loading: { | |
on: { | |
FAIL: 'failure', | |
LOADED: { | |
target: 'ready', | |
actions: assign({ | |
video: (context, event) => {}, | |
duration: (context, event) => {} | |
}) | |
} | |
} | |
}, | |
ready: { | |
initial: 'paused', | |
states: { | |
paused: { | |
on: { | |
PLAY: { | |
target: 'playing', | |
actions: 'playVideo' | |
} | |
} | |
}, | |
playing: { | |
on: { | |
PAUSE: { | |
target: 'paused', | |
actions: 'pauseVideo' | |
}, | |
END: 'ended', | |
TIMING: { | |
target: 'playing', | |
actions: assign({ | |
elapsed: ({video}, _event) => {} | |
}) | |
} | |
} | |
}, | |
ended: { | |
on: { | |
PLAY: { | |
target: 'playing', | |
actions: 'restartVideo' | |
} | |
} | |
} | |
} | |
}, | |
failure: { | |
type: 'final' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment