Skip to content

Commit

Permalink
Try to fix the scanner camera
Browse files Browse the repository at this point in the history
  • Loading branch information
yudong-0222 committed Feb 22, 2024
1 parent 5bc8ab1 commit acf33dd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/Scanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { getPlayerPuzzle } from '@/lib/getPlayerPuzzle';

const Scanner = () => {
const [IsgetData, setIsgetData] = useState(false);
const [facingMode, setFacingMode] = useState('user');

const toggleFacingMode = () => {
setFacingMode(prevMode => prevMode === 'user' ? 'environment' : 'user');
};
const [facingMode, setFacingMode] = useState('environment');

return (
<div className='flex justify-center items-center '>
Expand All @@ -28,7 +24,10 @@ const Scanner = () => {
constraints={{ facingMode: facingMode }}
/>
<div className=' justify-center text-center items-center'>
<button className='' onClick={toggleFacingMode}>切換鏡頭</button>
<select onChange={(e) => setFacingMode(e.target.value)}>
<option value={"environment"}>後置鏡頭</option>
<option value={"user"}>前置鏡頭</option>
</select>
</div>
</div>
{IsgetData && <InfoWindow msg="恭喜獲得一塊拼圖!!" onClose={() => setIsgetData(false)} />}
Expand Down

0 comments on commit acf33dd

Please sign in to comment.