[mythtv] MythGame screenshots

Jochen Kühner jochen.kuehner at gmx.de
Sun Aug 7 14:37:08 EDT 2005


If now tested the script a few times and made some enhanchments, but my 
major problem is that i can't get a programm run in background from within a 
php script (i tested it with zsnes.) php still waits until zsnes is closed.

i used the system function from php the & backgroun operator and > /dev null 
2>&1 but it doesn't work. any suggestions???
----- Original Message ----- 
From: "Jochen Kühner" <jochen.kuehner at gmx.de>
To: "'Development of mythtv'" <mythtv-dev at mythtv.org>
Sent: Friday, August 05, 2005 10:23 AM
Subject: AW: [mythtv] MythGame screenshots


> So here's Version 2 of my Example Script.
>
> Extensions are now proved.
> Could not Test anything at home, because my ati card's not working with my
> current kernel!
>
> So If anyone could test, if something happens
>
> <?php
> //   This is a Simple PHP Script to Generate Screenshots for the Rom's
> //   in the New MythGame. It goes through all GamePlayers, Run's them with
> //   all Roms and take a X Screenshot.
> //
> //  To Do:
> //    * go through Subdirectorys
> //    * Special Options for a Emulator (Example: If the Emu didn't use the
> //                               whole SCreen, strip Image with 
> ImageMagic)
> //    * if %s Variable is set in GamePlayer then use it instead of adding
> //      the romname to the back of the Player Name.
> //    * Screenshots are currently named $romname.png
> //              Example: Mario Kart.smc.png
> //      I think that must be changed (or not ??))
>
> //User defined Variables
> $db_user = "root";
> $db_pwd = "";
> $scrot_path = "";
> $pausetime = "5000000"; // (5000000 = 5 Seconds)
>
> //This normaly had not to be changed
> $db_name = "mythconverg";
>
> //Here begins the Script
>
> //Establish Database Connection
> $conn_id = mysql_connect("localhost",$db_user,$db_pwd);
> mysql_select_db($db_name,$conn_id);
>
> //Read GamePlayers
> $sql = "SELECT * FROM gameplayers;";
> $result_gamep = mysql_query($sql);
>
> //Do this for all GamePlayers
> for ($j=0;$j<@mysql_num_rows($result_gamep);$j++)
> {
>
>    //Get Values
>    $playername = mysql_result($result, $j, "playername");
>    $workingpath = mysql_result($result, $j, "workingpath");
>    $rompath = mysql_result($result, $j, "rompath");
>    $commandline = mysql_result($result, $j, "commandline");
>    $extensions = strtolower(mysql_result($result, $j, "extensions"));
>    $screenshots = mysql_result($result, $j, "screenshots");
>
>    //Is Screenshot Directory set??
>    if ($screenshots != "")
>    {
>       //
>       $directory = dir($rompath);
>       while($file = $directory->read())
>       {
>
>          if ($file != "." && $file != "..")
>          {
>
>             //File Extension Exists in List or none defined
>             $end = strtolower(substr($file,strlen($file)-3,3));
>
>             $get_ext = strcspn($extensions, $end);
>
>             if ($get_ext > 0 || $extensions == "")
>             {
>
>                //Emulator + Rom + & (Background Operator) + > /dev/null
> (keine ausgabe)
>                $command = trim($commandline)." ".$rompath.$file." & >
> /dev/null";
>                system($command);
>
>                //Wait the Pausetime befor taking the Screenshot
>                usleep($pausetime);
>
>                //Take the SCreenshot
>                $scrotcmd = $scrot_path + "scrot '".$file.".png' -e 'mv $f
> ".$screenshots."'";
>                system($scrotcmd);
>
>                //Kill the GamePlayer
>                $killcmd = "killall -9 ".$commandline;
>
>                //After this, wait half a Second, so that the emu is exited
>                usleep(500000);
>
>             }
>          }
>       }
>    }
>    else
>    {
>        echo "No Screenshot Directory set for Player: ".$playername.",
> skipping\n";
>    }
> }
> ?>
>


--------------------------------------------------------------------------------


_______________________________________________
mythtv-dev mailing list
mythtv-dev at mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev



More information about the mythtv-dev mailing list