This commit is contained in:
Fredrik Burmester
2024-09-13 13:19:29 +03:00
parent cd126bb1c7
commit f7e04dfa2d

View File

@@ -7,7 +7,7 @@ import { Ionicons } from "@expo/vector-icons";
import { BlurView } from "expo-blur"; import { BlurView } from "expo-blur";
import { useRouter, useSegments } from "expo-router"; import { useRouter, useSegments } from "expo-router";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import { Alert, Platform, TouchableOpacity, View } from "react-native"; import { Alert, Platform, TouchableOpacity, View } from "react-native";
import Animated, { import Animated, {
useAnimatedStyle, useAnimatedStyle,
@@ -47,6 +47,8 @@ export const CurrentlyPlayingBar: React.FC = () => {
const screenHeight = Dimensions.get("window").height; const screenHeight = Dimensions.get("window").height;
const screenWiidth = Dimensions.get("window").width; const screenWiidth = Dimensions.get("window").width;
const from = useMemo(() => segments[2], [segments]);
const backgroundValues = useSharedValue({ const backgroundValues = useSharedValue({
bottom: 70, bottom: 70,
height: 80, height: 80,
@@ -176,6 +178,12 @@ export const CurrentlyPlayingBar: React.FC = () => {
width: screenWiidth, width: screenWiidth,
left: 0, left: 0,
}; };
textValues.value = {
bottom: 78,
height: 64,
left: 16,
width: 140,
};
} else { } else {
backgroundValues.value = { backgroundValues.value = {
bottom: 70, bottom: 70,
@@ -207,6 +215,7 @@ export const CurrentlyPlayingBar: React.FC = () => {
const progress = useSharedValue(0); const progress = useSharedValue(0);
const min = useSharedValue(0); const min = useSharedValue(0);
const max = useSharedValue(currentlyPlaying?.item.RunTimeTicks || 0); const max = useSharedValue(currentlyPlaying?.item.RunTimeTicks || 0);
const sliding = useRef(false);
useEffect(() => { useEffect(() => {
max.value = currentlyPlaying?.item.RunTimeTicks || 0; max.value = currentlyPlaying?.item.RunTimeTicks || 0;
@@ -324,7 +333,9 @@ export const CurrentlyPlayingBar: React.FC = () => {
thread: true, thread: true,
}} }}
onProgress={(e) => { onProgress={(e) => {
if (sliding.current === true) return;
onProgress(e); onProgress(e);
progress.value = e.currentTime * 10000000;
}} }}
subtitleStyle={{ subtitleStyle={{
fontSize: 16, fontSize: 16,
@@ -384,10 +395,16 @@ export const CurrentlyPlayingBar: React.FC = () => {
bubbleTextColor: "#000", bubbleTextColor: "#000",
heartbeatColor: "#999", heartbeatColor: "#999",
}} }}
onSlidingStart={() => {
sliding.current = true;
}}
onSlidingComplete={(val) => { onSlidingComplete={(val) => {
const tick = Math.floor(val); const tick = Math.floor(val);
console.log(tick); videoRef.current?.seek(tick / 10000000);
videoRef.current?.seek(tick); sliding.current = false;
}}
onValueChange={(val) => {
const tick = Math.floor(val);
progress.value = tick; progress.value = tick;
}} }}
containerStyle={{ containerStyle={{