slider

mail@pastecode.io avatar
unknown
javascript
2 years ago
1.2 kB
4
Indexable
Never
const [current_time, setCurrentTime] = useState(0);
const [actual_time, setActualTime] = useState(0);
const [final_time, setFinalTime] = useState(0);

const play_music = async () => {
    if (icon === "play") {
        DeviceEventEmitter.emit("play", song);
        const play_object = await audioContext.get_play_object();
        const {durationMillis} = await play_object.getStatusAsync();
        play_object.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate => hola());
        setFinalTime(durationMillis);
        setIcon("pause");
    }else {
        DeviceEventEmitter.emit("pause");
        setIcon("play");
    }
}

const hola = async (onPlaybackStatusUpdate) => {
    const play_object = await audioContext.get_play_object();
    const {durationMillis, positionMillis} = await play_object.getStatusAsync();
    const current_time = positionMillis / durationMillis;
    if (current_time > 0) {
        setCurrentTime(current_time);
    }
      
}

   <Slider style = {{width: 300}} trackThickness = {10} thumbSize={12} minimumValue = {0} maximumValue = {final_time} value = {current_time} onValueChange = {value => {console.log("hola")}}>
    </Slider>