1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-05 09:36:41 +07:00
vault-frontend/src/redux/player/sagas.ts
2019-10-13 17:47:13 +07:00

24 lines
623 B
TypeScript

import { takeLatest } from 'redux-saga/effects';
import { PLAYER_ACTIONS } from './constants';
import { playerSetFile } from './actions';
import { Player } from '~/utils/player';
import { getURL } from '~/utils/dom';
function setFileSaga({ file }: ReturnType<typeof playerSetFile>) {
Player.set(getURL(file));
Player.play();
}
function playSaga() {
Player.play();
}
function pauseSaga() {
Player.pause();
}
export default function* playerSaga() {
yield takeLatest(PLAYER_ACTIONS.SET_FILE, setFileSaga);
yield takeLatest(PLAYER_ACTIONS.PAUSE, pauseSaga);
yield takeLatest(PLAYER_ACTIONS.PLAY, playSaga);
}