Saturday, July 27, 2013

How Install Flash Games on PirateBox

Although it was not designed for this, PirateBox can support browser games as well. It's main purpose is to allow anonymous file sharing and chat between the connected users, but hey, it doesn't hurt to have a little fun while sharing files right?
My TP-LINK MR3020 is loaded with a custom UI and I was experimenting to see if I can get some flash games running sort of "out of the box".

It turned out, it is simpler than I have imagined, flash games can be used on the PirateBox by simply copying them over and embedding them with <embed media>.

Here is a screenshot of the flash games running on my box:

Guide to Install a Game:


  1. Your PirateBox has to be version 0.5.1 or above, that is use lighttpd.
  2. Find the flash game you want on your box. Search on the internet what you like, e.g. mario, sonic and so on. After you found the game, download it on your computer. This should be an ".swf" file.
  3. Take your USB drive from the PirateBox and plug it in your computer. The file USB/PirateBox/pbIMG_ws.img has to be edited. This is an img file container mounted when the PirateBox starts and contains the UI files among others.
    This pbIMG_ws.img is 20 Mb by default so if you have a custom UI and 1-2 game you might need to create a bigger file container.

    To mount this file do:

    sudo mkdir -p /tmp/tmp_mount/ && sudo mount -o loop,rw,sync /media/[$usb]/PirateBox/pbIMG_ws.img /tmp/tmp_mount
    sudo chmod -R 777 /tmp/tmp_mount

    (Where [$usb] is the name of your USB drive)
  4. The file will be mounted at /tmp/tmp_mount/
    Navigate here and open the html file from the www folder you want to add the flash game to.
    Or create a new html page with the game in it. Don't forget to link this to the landing page, so itt will be easily available for users.
  5. Use the following code to embed the flash game into your site:

    <embed src="path/to/flash-game.swf"  type="application/x-shockwave-flash" name="obj1" width="600" height="450">

    src - path to the file within the www directory. Hence if you have a "games" folder in www then the route should be games/yourgame.swf
    width - width of the flash game (advised to keep original)
    height - height of the flash gem (advised to keep original)
  6. After finished, unmount the img container before ejecting the USB drive with:

    sudo umount /media/[$usb]/PirateBox/pbIMG_ws.img

  7. Eject your USB drive, plug in into your PirateBox and boot it.

NOTE:
The easiest way to quickly mount and unmount this
/media/[$usb]/PirateBox/pbIMG_ws.img
is to create a script that does this for you. 

Here is the script I wrote to make things easier for myself.

CAUTION: Flash games load by default in the browser. Therefore, many games on the same page (especially landing page) will most likely create an unnecessarily high load for the PirateBox. I would advise that you create separate html pages for games.



    2 comments:

    1. It turned out, it is simpler than I have imagined, flash games can be used on the PirateBox by simply copying them over and embedding them with . juegos friv gratis

      ReplyDelete