import React, { useState, useContext } from 'react'; import { ScrollView, Text, StyleSheet } from 'react-native'; import { Icon, Slider } from 'react-native-elements'; import C from 'rn-class'; import {PlayerStateContext, PlayerDispatchContext, playerCommon} from './PlayerReducer'; export default props => { const { Pages, currentPlayerValue, setCurrentPlayerValue} = props; const [curPlayerValue, setCurPlayerValue] = useState(0); const [isPlay, setPlay] = useState(false); const playerDispatch = useContext(PlayerDispatchContext); const playerState = useContext(PlayerStateContext); const {paused, player, duration, currentTime} = playerState; const { secondsTohhmmss } = playerCommon; const onSetPlay = () => { //setPlay(!isPlay); playerDispatch({type:'paused', setPaused:!paused}); //console.log(player); }; const onStop = () => { playerDispatch({type:'stop'}); } // const getpercent = () => { // console.log((parseFloat(currentTime) / parseFloat(duration))*100-1) // if(currentTime>0) { // return (parseFloat(currentTime) / parseFloat(duration))*100 // } // } const onForwardRewind = (type) => { if(type==='rewind') { playerDispatch({type: 'seek', seekValue: currentTime - 15}) } if(type==='forward') { playerDispatch({type: 'seek', seekValue: currentTime + 15}) } } return ( {Pages.subtitle} {Pages.subtitle} {Pages.contens} by {Pages.subtitle.replace(/\r\n|\n|\r/gm, ' ')} March 19 {onForwardRewind('rewind')}} /> { paused===false ? : } {onForwardRewind('forward')}} /> {/* {Math.floor(currentTime)} */} playerDispatch({type: 'seek', seekValue: Math.floor(value)})} /> {secondsTohhmmss(currentTime)} {secondsTohhmmss(duration)} ); };