Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:32:56+00:00 2026-06-13T03:32:56+00:00

I need to play a .swf file then when the file is changed to

  • 0

I need to play a .swf file then when the file is changed to reload the player with new content. Sadly, my program of choice does not do monitor files for changes. I came up with a bit convoluted solution:

sudo apt-get install incron gtk-gnash
echo "my_username" | sudo tee -a /etc/incron.allow # allow my_username to run incron
incrontab -e

add the following to incrontab:

/home/my_username/path/myfile.swf IN_MODIFY /home/my_username/path/run.sh

and the run.sh contains: ( also chmod 700 run.sh)

#!/bin/sh
killall gtk-gnash
gtk-gnash /home/my_username/path/myfile.swf

As you can see this is far from elegant. How else could I go about this?

This is on Ubuntu 12.04 if that matters for you. This is a duplicate of my own question on askubuntu

EDIT: clarification, I chose to use gtk-gnash, a standalone player, this is not required, a web browser would do too but seems not necessary

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:32:57+00:00Added an answer on June 13, 2026 at 3:32 am

    What you’re describing is the job of a File Alteration Monitor.

    First off, your existing “incrontab” solution is a good starting point, given that you’re launching things from shell. The fact that incrontab is an inotify(7)-based solution is a huge plus. It means that you aren’t polling, which saves CPU.

    You’re asking for shell and system-level solutions, and I’m not a Flash programmer, so I’ll stick to your question, though I think a better solution would be to create a Flash “wrapper” that perhaps uses an AS3 Loader class to suck in your existing SWF and receive notifications from something launched by incrontab. Flash programming is way out of scope for this answer, though it might provide a more elegant solution.

    So…

    Your current method consists of a launch script that first kills any existing gtk-gnash process then runs a new one. It gets relaunched from scratch when incrontab sees a change to the file. That’s a viable solution if you trust that your flash application will never crash and quit, and if you always have perfect timing. One problem with it is that you’ve got an unknown delay between the death of one process and the start of the next. Your killall sends a signal, which gtk-gnash may respond to immediately, or after a pause. With a short pause, you might find yourself launching the SWF before the old one is fully gone. With a longer pause, you may briefly show your desktop.

    A better solution might be simply to launch the SWF within a loop:

    #!/bin/sh
    
    while true; do
        date '+[%Y-%m-%d %T] myfile.swf relaunched' >> /var/log/swf.log
        gtk-gnash /home/my_username/path/myfile.swf
    done
    

    Then have incrontab merely kill the existing process:

    /home/my_username/path/myfile.swf IN_MODIFY killall gtk-gnash
    

    By separating the killall from the launch, you make sure that the new instance of gtk-gnash does not start until the old one has actually quit and returned control to the shell script wrapping it.

    Of course, instead of using incrontab, you could alternatively install the inotify-tools package and leave a loop running:

    #!/bin/sh
    while inotifywait -e modify /home/my_username/path/myfile.swf; do
        killall gtk-gnash
    done
    

    Same syscalls, same effect, different front-end.

    If you want to be über-careful about what process you’re killing, you can also store the pid of gtk-gnash in a temporary file. Here’s another take on the flash player wrapper:

    #!/bin/sh
    
    while true; do
        date '+[%Y-%m-%d %T] myfile.swf relaunched' >> /var/log/swf.log
        gtk-gnash /home/my_username/path/myfile.swf &
        echo $! > /var/run/gtk-gnash.pid
        wait
    done
    

    And the incrontab line:

    /home/my_username/path/myfile.swf IN_MODIFY xargs kill < /var/run/gtk-gnash.pid
    

    Another strategy you might employ to reduce the visible effect of the kill/restart, is to take a screenshot of myfile.swf while it is running with minimal or no content, then use that as the desktop wallpaper on the player. (Or equivalent. I don’t know how you’re set up.) I did something similar for a digital signage solution I set up a few years ago — from time to time we needed to kill and restart a standalone player, so we made just the “frame” of the first page that shows up. When we killed the flashplayer process, the system “seemed” to reset with no content in its boxes … and then, a second later, content would show up. (Yes, it’s a hack.)

    One other tip: I’ve always found Adobe’s stand-alone Flash player (“Projector”) to be more reliable and more compatible than gtk-gnash. You can find Adobe’s stand-alone player at the Adobe Support Centre Download Page, which is different from their standard Flash Player download page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to play a .swf flash file when i mouse over one of
I need to play Music Library files using file URL, that I will set
I need to play a part of an MP3 file in my java code.
I have an aes encrypted mp3 file that I need to play in iOS;
I need to play video file (using installed codecs) and get some file info
I need to play SWF files in my project. These SWF files have background
I need to play on my .swf a movie (h264) from the users' hard
i want to play some swf movie in my page and i need a
basically, I have an swf file that is set to play 10 seconds after
i have an swf media player which play flv videos but i want it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.