diff --git a/src/screens/Library/components/MusicCard.js b/src/screens/Library/components/MusicCard.js index 7807aef..974e2a9 100644 --- a/src/screens/Library/components/MusicCard.js +++ b/src/screens/Library/components/MusicCard.js @@ -141,7 +141,7 @@ const MusicCard = ({ // Platform.OS !== "ios" ? "dimezisBlurView" : "none" // } > - + {title || "Sans titre"} diff --git a/src/screens/Library/components/SearchResultsList.js b/src/screens/Library/components/SearchResultsList.js index 29c3cf2..abc3c7b 100644 --- a/src/screens/Library/components/SearchResultsList.js +++ b/src/screens/Library/components/SearchResultsList.js @@ -89,105 +89,91 @@ const SearchResultsList = ({ showsVerticalScrollIndicator={false} > {shouldShowMusics && ( - - - {musics.length > 0 && ( - - {Array.isArray(musics) && - musics.slice(0, 6).map((project) => ( - handleMusicPress(project)} - onPressMore={(positionTop) => { - setSelectedProjectId(project.id); - setMenuPosition(positionTop); - setShowMenu( - (previous) => - !previous || - positionTop?.top !== (menuPosition?.top ?? null) - ); - }} - /> - ))} - {musicsLoading && ( - + {musics.length > 0 && ( + <> + {Array.isArray(musics) && + musics.slice(0, 6).map((project) => ( + handleMusicPress(project)} + onPressMore={(positionTop) => { + setSelectedProjectId(project.id); + setMenuPosition(positionTop); + setShowMenu( + (previous) => + !previous || + positionTop?.top !== (menuPosition?.top ?? null) + ); }} - > - {"Chargement…"} - - )} - - )} - {musics.length === 0 && !musicsLoading && ( - - )} - + /> + ))} + {musicsLoading && ( + + {"Chargement…"} + + )} + + )} + {musics.length === 0 && !musicsLoading && ( + + )} )} {shouldShowPlaybacks && ( - - - {playbacks.length > 0 && ( - - {Array.isArray(playbacks) && - playbacks.slice(0, 6).map((project) => ( - handlePlaybackPress(project)} - onPressMore={(positionTop) => { - setSelectedProjectId(project.id); - setMenuPosition(positionTop); - setShowMenu( - (previous) => - !previous || - positionTop?.top !== (menuPosition?.top ?? null) - ); - }} - /> - ))} - {playbacksLoading && ( - + {playbacks.length > 0 && ( + <> + {Array.isArray(playbacks) && + playbacks.slice(0, 6).map((project) => ( + handlePlaybackPress(project)} + onPressMore={(positionTop) => { + setSelectedProjectId(project.id); + setMenuPosition(positionTop); + setShowMenu( + (previous) => + !previous || + positionTop?.top !== (menuPosition?.top ?? null) + ); }} - > - {"Chargement…"} - - )} - - )} - {playbacks.length === 0 && !playbacksLoading && ( - - )} - + /> + ))} + {playbacksLoading && ( + + {"Chargement…"} + + )} + + )} + {playbacks.length === 0 && !playbacksLoading && ( + + )} )} {shouldShowUsers && ( diff --git a/src/screens/Playbacks/Playbacks.js b/src/screens/Playbacks/Playbacks.js index ffc537e..e784ada 100644 --- a/src/screens/Playbacks/Playbacks.js +++ b/src/screens/Playbacks/Playbacks.js @@ -21,7 +21,6 @@ import { usersRef, } from "../../config/firebase"; import useDataFromRef from "../../hooks/useDataFromRef"; -import useSharedAudioPlayer from "../../hooks/useSharedAudioPlayer"; import { Routes } from "../../navigation"; import { navigate } from "../../navigation/NavigationService"; import { useUser } from "../../providers/UserDataProvider"; @@ -32,13 +31,6 @@ import { size } from "../../styles/Style"; const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => { const { currentUID, followUser, unfollowUser } = useUser() || {}; const videoUrl = item?.playbackUrl || null; - const audioSource = useMemo(() => { - const fromSong = item?.songUrl ? { uri: item.songUrl } : null; - return fromSong; - }, [item]); - - const hasExternalAudio = !!audioSource; - const initialLikedBy = Array.isArray(item?.likedBy) ? item.likedBy : []; const [isLiked, setIsLiked] = useState( currentUID ? initialLikedBy.includes(currentUID) : false @@ -116,21 +108,9 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => { const creatorName = item?.userName; - const audioPlayer = useSharedAudioPlayer(audioSource || undefined, { - id: item?.id - ? `playback-${item.id}` - : audioSource?.uri - ? `playback-${audioSource.uri}` - : undefined, - title: typeof item?.title === "string" ? item.title : "", - artist: typeof item?.userName === "string" ? item.userName : "", - artwork: item?.coverUrl || null, - coverUrl: item?.coverUrl || null, - metadata: { playbackId: item?.id }, - }); const videoPlayer = useVideoPlayer(videoUrl || null, (p) => { p.loop = false; - p.muted = true; + p.muted = false; p.timeUpdateEventInterval = 0.2; }); @@ -138,9 +118,6 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => { const toggle = async () => { try { if (isActive) { - try { - if (audioPlayer && hasExternalAudio) await audioPlayer.seekTo?.(0); - } catch (e) {} try { if (videoPlayer) videoPlayer.currentTime = 0; } catch (e) {} @@ -149,41 +126,21 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => { try { if (videoPlayer) videoPlayer.play(); } catch (e) {} - try { - if (audioPlayer && hasExternalAudio) audioPlayer.play?.(); - } catch (e) {} } else { - if (audioPlayer?.playing) await audioPlayer.pause?.(); if (videoPlayer?.playing) videoPlayer.pause(); } } catch (e) {} }; toggle(); - }, [isActive, audioPlayer, videoPlayer, hasExternalAudio]); - - // Micro-correction initiale uniquement pour absorber un léger décalage réseau - useEffect(() => { - if (!isActive || !hasExternalAudio) return; - const t = global.setTimeout(() => { - try { - const a = audioPlayer?.currentTime || 0; - const v = videoPlayer?.currentTime || 0; - if (Math.abs(a - v) > 0.2 && videoPlayer) { - videoPlayer.currentTime = Math.max(0, a); - } - } catch (e) {} - }, 300); - return () => global.clearTimeout(t); - }, [isActive, hasExternalAudio, audioPlayer, videoPlayer]); + }, [isActive, videoPlayer]); useEffect(() => { return () => { try { - if (audioPlayer?.playing) audioPlayer.pause?.(); if (videoPlayer?.playing) videoPlayer.pause(); } catch (e) {} }; - }, [audioPlayer, videoPlayer]); + }, [videoPlayer]); // Build alignedWords from item musicTimestamps const alignedWords = useMemo(() => { @@ -204,14 +161,11 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => { if (!isActive) return; const id = global.setInterval(() => { try { - const t = hasExternalAudio - ? Number(audioPlayer?.currentTime || 0) - : Number(videoPlayer?.currentTime || 0); - setCurrentTimeS(t); + setCurrentTimeS(Number(videoPlayer?.currentTime || 0)); } catch (e) {} }, 250); return () => global.clearInterval(id); - }, [isActive, hasExternalAudio, audioPlayer, videoPlayer]); + }, [isActive, videoPlayer]); // partage: géré via l'API native Share directement dans l'UI return ( diff --git a/src/screens/Playbacks/components/PlaybackItem.web.js b/src/screens/Playbacks/components/PlaybackItem.web.js index 8393ac7..5450798 100644 --- a/src/screens/Playbacks/components/PlaybackItem.web.js +++ b/src/screens/Playbacks/components/PlaybackItem.web.js @@ -23,7 +23,6 @@ import { projectsRef, usersRef, } from "../../../config/firebase"; -import useSharedAudioPlayer from "../../../hooks/useSharedAudioPlayer"; import { Routes } from "../../../navigation"; import { navigate } from "../../../navigation/NavigationService"; import { useUser } from "../../../providers/UserDataProvider"; @@ -37,8 +36,7 @@ const DEBUG_PLAYBACK_WEB = true; // NOTE: Web-only implementation that uses a native