Live video on the AT Protocol
at next 23 lines 664 B view raw
1import { Dimensions } from "react-native"; 2import { usePlayerStore } from "../player-store"; 3 4/** 5 * usePlayerDimensions 6 * Returns player and device dimensions, and whether the player aspect ratio is greater than the device's. 7 */ 8export function usePlayerDimensions() { 9 const { width, height } = Dimensions.get("window"); 10 const pHeight = Number(usePlayerStore((x) => x.playerHeight)) || 0; 11 const pWidth = Number(usePlayerStore((x) => x.playerWidth)) || 0; 12 13 const isPlayerRatioGreater = 14 pHeight > 0 && pWidth > 0 ? pWidth / pHeight > width / height : false; 15 16 return { 17 width, 18 height, 19 pWidth, 20 pHeight, 21 isPlayerRatioGreater, 22 }; 23}