Angular 4中ack-angular-webcam组件IE下SWF文件404问题求助
Hey there, let's break down why your webcam component is throwing a 404 for the Flash fallback in IE—especially since it worked fine a month ago and you haven't touched your code. Here are the most likely fixes to try:
1. Verify the Flash SWF File's Path & Presence
First, let's track down where that missing SWF is supposed to be:
- Open IE's Developer Tools (hit F12), go to the Network tab, and look for the failed SWF request. Note the exact URL it's trying to load.
- Check if the SWF file exists in your project:
- If you installed the library via npm, look in
node_modules/ack-angular-webcamfor any.swffiles. - Make sure this file is being copied to your deployed static assets folder (like
assets/in Angular). If your build process isn't including it, add it to yourangular.jsonassets config to ensure it gets deployed.
- If you installed the library via npm, look in
- Update your component's options to point to the correct SWF path explicitly:
options = { audio: false, video: true, fallbackMode: 'flash', fallbackSrc: '/assets/webcam.swf' // Replace with your actual SWF path // Keep other existing configs };
2. Check for Unintended Dependency Updates
Even if you didn't modify your code, your package manager might have pulled an updated version of ack-angular-webcam (e.g., if your package.json uses a loose version constraint like ^x.y.z). Newer versions might have removed the SWF file or changed its location.
- Check your
package-lock.jsonoryarn.lockto see if the library version changed recently. - Reinstall the exact version that worked a month ago:
npm install ack-angular-webcam@<your-working-version-number>
3. Disable Flash Fallback (If IE Support Isn't Critical)
Since Microsoft has fully ended Flash support, IE's Flash plugin is likely disabled or removed on most systems anyway. If your user base no longer relies on IE, you can force the component to skip the Flash fallback entirely:
options = { audio: false, video: true, force_flash: false, fallback: false // Keep other existing configs };
This will make the component only use the modern getUserMedia() API (which works in Chrome/Firefox) and fail gracefully in IE—you can add a user-friendly message asking IE users to switch to a modern browser.
4. Consider Migrating to a Modern Webcam Component
Long-term, ack-angular-webcam's Flash dependency is a liability since Flash is obsolete. Look into modern alternatives that rely solely on the MediaDevices API, which is supported in all current browsers and doesn't need Flash fallback.
内容的提问来源于stack exchange,提问作者Lokesh Kumar Meena

