Linux – Firefox trying to download local .swf files

firefoxflash-playerlinux

I'm quite annoyed with my firefox and Flash files :

When I try opening a .swf file with it:

  • If the file is on the web (via http://...), it plays normally in browser
  • If the file is local (via file:///...), firefox only show me a dialog to download it

It tried opening a web swf file, downloading it then opening it locally, it's the same. So I guess it's a firefox problem.

I'm on Gentoo Linux, and it started today, without any apparent reason.

Best Answer

After some digging into this myself, I've discovered it is a MIME type issue. Firefox (or Chrome) on Linux won't play SWF files if it thinks the type is application/vnd.adobe.flash.movie.

Per https://askubuntu.com/questions/478169/why-cant-firefox-run-local-swf-files:

Edit /usr/share/mime/packages/freedesktop.org.xml as root and replace the following:

<mime-type type="application/vnd.adobe.flash.movie">

With:

<mime-type type="application/x-shockwave-flash">

And then run:

update-mime-database /usr/share/mime

I found I needed to restart Firefox after. Here's a script very close to one from http://ubuntuforums.org/showthread.php?t=2218732&page=2 that performs these steps (run it with sudo), but I will warn you -- I noticed that different installs seem to have different spacing, which can trip up the sed script, which is what happened to me.

#!/bin/bash
clear
echo "Update file freedesktop.org.xml...";
sed  -e "s/<mime-type type=\"application\/vnd.adobe.flash.movie\">/<mime-type type=\"application\/x-shockwave-flash\">/g"  /usr/share/mime/packages/freedesktop.org.xml >  /usr/share/mime/packages/freedesktop.org.xml.new
mv /usr/share/mime/packages/freedesktop.org.xml /usr/share/mime/packages/freedesktop.org.xml.original
mv /usr/share/mime/packages/freedesktop.org.xml.new /usr/share/mime/packages/freedesktop.org.xml
echo "File updated successfully!";
echo "Update mime database...";
update-mime-database /usr/share/mime
echo "Mime database updated successfully! ALL DONE!";
Related Question