A simple frontend application that verifies browser camera access and basic media stream handling using native Web APIs.
This project was built as part of Frontend Shortlisting Task 2 – Simple Camera Test (MERN).
- Verify browser camera access
- Handle media streams correctly
- Maintain clean UI state transitions
Design is not evaluated Functionality and correctness are the focus
- Next.js (App Router)
- React
- Tailwind CSS
- TypeScript
- Native Browser Web APIs only
No UI templates or third-party camera libraries were used.
🔗 Live URL: https://camera-testing-application.vercel.app/
🔗 GitHub Repo: https://github.com/gmprinceyt
- Static landing page
- Title: Camera Test App
- Button: Start Camera Test
- Navigates to
/camera-test
This page handles the full camera testing flow.
-
Triggered on button click
-
Uses:
navigator.mediaDevices.getUserMedia({ video: true })
| State | Behavior |
|---|---|
| Allowed | Shows “Camera is working ✅” |
| Denied | Shows clear error message |
| Error | Graceful fallback message |
-
Displays live video feed using
<video> -
Shows text:
Live camera preview active
❌ No photo capture ❌ No recording
-
Stop Camera button:
- Stops all media tracks
- Releases camera properly
- Shows “Camera stopped”
-
Retry button:
- Restarts camera test
- Media logic handled inside a reusable
useCamerahook - UI state managed separately in components
- Reusable Button component for consistent UI
-
All media tracks are stopped:
- When camera is stopped
- When component unmounts
-
Prevents memory leaks and background camera usage
- Start button is disabled during permission request
- Loading spinner shown while camera starts
- Clear messaging for permission denial
- Fully responsive layout (mobile-safe)
- Uses
playsInlineandmutedfor mobile compatibility
- ✅ Chrome
- ✅ Edge
(Mobile browsers supported where camera APIs are available)
-
Detects available cameras using:
navigator.mediaDevices.enumerateDevices()
-
Allows switching between cameras via dropdown
-
Switching works by:
- Stopping current stream
- Restarting with selected
deviceId
-
On mobile, defaults to front camera using:
facingMode: "user"
-
Displays actual camera resolution after stream starts
-
Resolution is read from:
MediaStreamTrack.getSettings()
-
Example:
Resolution: 1280 × 720
git clone https://github.com/gmprinceyt/camera-testing-application.git
cd camera-test-app
pnpm install
pnpm run devOpen: http://localhost:3000
- No photo capture or recording (out of scope)
- Camera labels depend on browser/device
- If permission is denied, browser popup will not reappear automatically (browser security behavior)
This project demonstrates:
- Correct usage of browser camera APIs
- Clean UI state management
- Proper media stream cleanup
- Mobile-friendly camera handling
- Bonus features implemented without external libraries
Prince developer