모바일 곡 상세: YouTube 전체화면 시 자동 가로 회전 시도

This commit is contained in:
caadiq 2026-01-12 18:58:06 +09:00
parent b5f668a8f9
commit db6949d53e

View file

@ -1,4 +1,4 @@
import { useState, useMemo } from 'react'; import { useState, useMemo, useEffect } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom'; import { useParams, useNavigate, Link } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
@ -43,6 +43,42 @@ function TrackDetail() {
// //
const [showFullLyrics, setShowFullLyrics] = useState(false); const [showFullLyrics, setShowFullLyrics] = useState(false);
//
useEffect(() => {
const handleFullscreenChange = async () => {
const isFullscreen = !!document.fullscreenElement;
if (isFullscreen) {
//
try {
if (screen.orientation && screen.orientation.lock) {
await screen.orientation.lock('landscape');
}
} catch (e) {
//
console.log('Screen orientation lock not supported');
}
} else {
//
try {
if (screen.orientation && screen.orientation.unlock) {
screen.orientation.unlock();
}
} catch (e) {
//
}
}
};
document.addEventListener('fullscreenchange', handleFullscreenChange);
document.addEventListener('webkitfullscreenchange', handleFullscreenChange);
return () => {
document.removeEventListener('fullscreenchange', handleFullscreenChange);
document.removeEventListener('webkitfullscreenchange', handleFullscreenChange);
};
}, []);
if (loading) { if (loading) {
return ( return (
<div className="flex justify-center items-center min-h-[60vh]"> <div className="flex justify-center items-center min-h-[60vh]">