Jump to content

Flash player problem


Recommended Posts

I have a flash player I use to play my flash games. I didn't make it, but I did tweak it to suit my taste. Normally, it works fine. I notice when I attempt to use it on a PC with IE7, it will not work. I figure it is a permission's issue, but I rather fix the script so that isn't a issue. I can go to a website that has the game, and it will play. I attempt to play from the player, and nothing. :whistle:

Note: I plan to intergrate a flash grabber script into this, so it is a one stop shop.

Here is the code for the player.

#include <GuiList.au3>
#include <Array.au3>
#include <ie.au3>
Dim $selection, $Form1
Dim $selection2
If FileExists(@ScriptDir & "\bin\Fconfig.ini") = 0 Then
    DirCreate(@ScriptDir & "\bin")
    IniWrite(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "2")
    DirCreate(@ScriptDir & "\games")
EndIf
GUICreate("Flash Player by Volly", 300, 300, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$FileList = _FileListToArray (@ScriptDir & "\games\", "*.swf", 1)
$atr = _ArrayTrim($FileList, 4, 1, 1)
$st = _ArrayToString($atr, "|", 1)
$Edit_1 = GUICtrlCreateList("", 20, 30, 170, 250)
GUICtrlSetData($Edit_1, $st)
$Button_2 = GUICtrlCreateButton("Play Game", 205, 30, 80, 30)
$Button_3 = GUICtrlCreateButton("Exit", 205, 75, 80, 30)
$Button_4 = GUICtrlCreateButton("Help", 205, 120, 80, 30)
$lable_1 = GUICtrlCreateLabel("Player size", 205, 165, 80, 30)
$Combo_5 = GUICtrlCreateCombo("", 205, 185, 80, 30)
$inir_0 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "Normal")
GUICtrlSetData($Combo_5, "Small|Normal|Large|Supersize", $inir_0)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_2
            $read = GUICtrlRead($Edit_1)
            If $read = "" Then
                MsgBox(48, "Opps!", "You didn't select a game.")
            Else
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", GUICtrlRead($Combo_5))
                $selection = $read & ".swf"
                GUISetState(@SW_HIDE)
                _viewer()
                GUISetState(@SW_SHOW)
            EndIf
        Case $msg = $Button_3
            Exit
        Case $msg = $Button_4
            MsgBox(64, "", " To add a Shockwave file to the list, you will need to copy" & @CRLF _
                     & "the file to the 'games' directory. Name the file so that you" & @CRLF _
                     & "will know what it is in the list. It will need to have the *.swf" & @CRLF _
                     & "file extension. When it is displayed in the player the *.swf" & @CRLF _
                     & "will not be shown.") 
        Case Else
            ;;;
    EndSelect
WEnd
Exit

Func _viewer()
    Local $W, $H
    $inir_1 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "")
    $inir_2 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "game", $read, "Show All")
    If $inir_1 = "small" Then
        $W = @DesktopWidth - 420
        $H = @DesktopHeight - 350
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Normal" Then
        $W = @DesktopWidth - 320
        $H = @DesktopHeight - 250
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Large" Then
        $W = @DesktopWidth - 220
        $H = @DesktopHeight - 150
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Supersize" Then
        $W = @DesktopWidth - 170
        $H = @DesktopHeight - 100
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    $getz = WinGetClientSize($Form1)
    $get2 = ($getz[0] * .38)
    $get2b = ($getz[1] * .93)
    $getL = StringLen($get2)
    $getLb = StringLen($get2b)
    $get3 = StringInStr($get2, ".")
    If $get3 = 0 Then $get3 = $get2
    $get3b = StringInStr($get2b, ".")
    If $get3b = 0 Then $get3b = $get2b
    $lenth = ($getL - $get3)
    $lenthb = ($getLb - $get3b)
    $ans = StringTrimRight($get2, $lenth + 1)
    $ansb = StringTrimRight($get2b, $lenthb + 1)
    $Obj = _IECreateEmbedded ()
    $browser = GUICtrlCreateObj ($Obj, 8, 8, $W - 20, $H - 70)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    _IENavigate ($Obj, 'about:blank')
    $oDoc = _IEDocGetObj ($Obj)
    $oDoc.body.style.overflow = "auto"
    $oDoc.body.style.margin = "0px"
    $oDoc.body.style.padding = "0px"
    If $inir_1 = "Normal" Or "Large" Or "Supersize" Then $xx = 0
    If $inir_1 = "Small" Then $xx = -15
    $button_6 = GUICtrlCreateButton("End Game", $ans, $ansb + $xx, 80, 30)
    $drop_down_10 = GUICtrlCreateCombo("", $ans + 90, $ansb + ($xx + 4), 80, 20)
    GUICtrlSetData($drop_down_10, "Show All|No Border|No Scale", $inir_2)
    GUISetState(@SW_SHOW)
    $flash1 = @ScriptDir & "\games\" & $selection
    $sHTML = '<embed id=flashy src="' & $flash1 & '" '
    $sHTML &= 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
    $sHTML &= 'type="application/x-shockwave-flash" '
    $sHTML &= 'width="100%" height="100%"></embed>'
    _IEBodyWriteHTML ($Obj, $sHTML)
    sleep(500)
    $Obj1 = _IEGetObjByName ($Obj, "flashy")
    If $inir_1 = "Show All" Then $Obj1.ScaleMode = 0
    If $inir_1 = "No Border" Then $Obj1.ScaleMode = 1
    If $inir_1 = "No Scale" Then $Obj1.ScaleMode = 3
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $dataread = GUICtrlRead($drop_down_10)
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "game", $read, $dataread)
                GUIDelete($Form1)
                ExitLoop
            Case $button_6
                $dataread = GUICtrlRead($drop_down_10)
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "game", $read, $dataread)
                GUIDelete($Form1)
                ExitLoop
            Case $drop_down_10
                $dataread = GUICtrlRead($drop_down_10)
                If $dataread = "Show All" Then $Obj1.ScaleMode = 0
                If $dataread = "No Border" Then $Obj1.ScaleMode = 1
                If $dataread = "No Scale" Then $Obj1.ScaleMode = 3
        EndSwitch
    WEnd
EndFunc   ;==>_viewer
Link to comment
Share on other sites

I have a flash player I use to play my flash games. I didn't make it, but I did tweak it to suit my taste. Normally, it works fine. I notice when I attempt to use it on a PC with IE7, it will not work. I figure it is a permission's issue, but I rather fix the script so that isn't a issue. I can go to a website that has the game, and it will play. I attempt to play from the player, and nothing. :whistle:

I didn't look at the code, but is it that you just need to get the flash plugin fo IE7?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Ummm, I don't think you understand my post. I can run the flash game if I go to a website that host it via IE7. If I attempt to load the same game via the player, it will not work. My viewer runs, but the area the game is shown is simply blank. When you read the sorce code for the field it is <html></html>. If I attempt to open the game that is saved in the games folder in my local PC with IE7, I get a security warning. If I click yes, the game will open.

I suspect the issue can be fixed in the code, but I need to know how to fix it.

Edited by Volly
Link to comment
Share on other sites

You are loading the SWF file from your C drive, correct? What happens when you open the SWF file from C with IE7 directly, instead of through the Flashy script? I believe it's a Flash security setting:

3. URL buttons doesn't work when playing flash file locally on computer. 2693

By default version 8 of the Flash Player does not allow opening external sites from a locally played flash file. This security setting can be changed at the following website: http://www.macromedia.com/support/document..._manager04.html

From that page, you can specify local folders which are allowed to run Flash files.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

You are loading the SWF file from your C drive, correct? What happens when you open the SWF file from C with IE7 directly, instead of through the Flashy script? I believe it's a Flash security setting:

From that page, you can specify local folders which are allowed to run Flash files.

doesn't work. Can someone test my player with IE7 to see if it is just my laptop?

:whistle:

Link to comment
Share on other sites

seems too obvious, but how about this:

$flash1 = @ScriptDir & "\games\" & $selection
if not fileExists($flash1) then
msgbox(16,"File Not Found",$flash1)
exit
endif
    $sHTML = '<embed id=flashy src="' & $flash1 & '" '
    $sHTML &= 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
    $sHTML &= 'type="application/x-shockwave-flash" '
    $sHTML &= 'width="100%" height="100%"></embed>'

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

@lod3n: I tested your code, and it is the same as what I had, except the safety if the file doesn't exist. I noticed in your player example, you have the following:

$flash.Movie = $filename

I was thinking this would load the swf file after the GUI is visible.

I tried this, and it didn't work. I get a error saying "The requested action with this object has failed.:"

$flash1 = @ScriptDir & "\games\" & $selection; file tested is @scriptdir&"/games/DesktopTD15k.swf"
    if not fileExists($flash1) then
        msgbox(16,"File Not Found",$flash1)
        exit
    endif
    $sHTML = '<embed id=flashy src="' & $flash1 & '" '
    $sHTML &= 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
    $sHTML &= 'type="application/x-shockwave-flash" '
    $sHTML &= 'width="100%" height="100%"></embed>'
    _IEBodyWriteHTML ($Obj, $sHTML)
    sleep(500)
    $Obj1 = _IEGetObjByName ($Obj, "flashy")
    $Obj1.Movie = $flash1
Edited by Volly
Link to comment
Share on other sites

By posting count, I'd say you're more likely the Master - however I've been having weird dreams about your problem over the weekend, so here's some potentially usable outcomes of those dreams:

I don't have IE7 or Vista with which to test. Try temporarily disabling IE7's protected mode:

http://support.cox.com/sdccommon/asp/conte...82-4390a7094c0c

Another thing: I've noticed that switching from "about:config" to some other page causes random security problems with the IE control. How about you FileWrite your $sHTML to a temp file, and then _IENavigate there initially.

Also, if my Flashy script works, and your original one does not, why not just start adding code to Flashy until it reaches the same level of functionality or breaks?

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

I got it to work!! YIPEE!!!!

The problem was I needed to add some stuff for the flash file to load. Here is the player in its current form. I still plan to add the flash grabber to it later.

#Include <File.au3>
#include <GuiConstants.au3>
#include <GuiList.au3>
#include <Array.au3>
#include <ie.au3>
Dim $selection, $Form1, $flash, $Obj, $gui
Dim $selection2
If FileExists(@ScriptDir & "\bin\Fconfig.ini") = 0 Then
    DirCreate(@ScriptDir & "\bin")
    IniWrite(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "2")
    DirCreate(@ScriptDir & "\games")
EndIf
GUICreate("Flash Player by Volly", 300, 300, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$FileList = _FileListToArray (@ScriptDir & "\games\", "*.swf", 1)
$atr = _ArrayTrim($FileList, 4, 1, 1)
$st = _ArrayToString($atr, "|", 1)
$Edit_1 = GUICtrlCreateList("", 20, 30, 170, 250)
GUICtrlSetData($Edit_1, $st)
$Button_2 = GUICtrlCreateButton("Play Game", 205, 30, 80, 30)
$Button_3 = GUICtrlCreateButton("Exit", 205, 75, 80, 30)
$Button_4 = GUICtrlCreateButton("Help", 205, 120, 80, 30)
$lable_1 = GUICtrlCreateLabel("Player size", 205, 165, 80, 30)
$Combo_5 = GUICtrlCreateCombo("", 205, 185, 80, 30)
$inir_0 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "Normal")
GUICtrlSetData($Combo_5, "Small|Normal|Large|Supersize", $inir_0)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_2
            $read = GUICtrlRead($Edit_1)
            If $read = "" Then
                MsgBox(48, "Opps!", "You didn't select a game.")
            Else
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", GUICtrlRead($Combo_5))
                $selection = $read & ".swf"
                GUISetState(@SW_HIDE)
                _viewer()
                GUISetState(@SW_SHOW)
            EndIf
        Case $msg = $Button_3
            Exit
        Case $msg = $Button_4
            MsgBox(64, "", " To add a Shockwave file to the list, you will need to copy" & @CRLF _
                     & "the file to the 'games' directory. Name the file so that you" & @CRLF _
                     & "will know what it is in the list. It will need to have the *.swf" & @CRLF _
                     & "file extension. When it is displayed in the player the *.swf" & @CRLF _
                     & "will not be shown.") 
        Case Else
            ;;;
    EndSelect
WEnd
Exit

Func _viewer()
    Local $W, $H
    $inir_1 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "settings", "size", "")
    $inir_2 = IniRead(@ScriptDir & "\bin\Fconfig.ini", "game", $read, "Show All")
    If $inir_1 = "small" Then
        $W = @DesktopWidth - 420
        $H = @DesktopHeight - 350
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Normal" Then
        $W = @DesktopWidth - 320
        $H = @DesktopHeight - 250
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Large" Then
        $W = @DesktopWidth - 220
        $H = @DesktopHeight - 150
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    If $inir_1 = "Supersize" Then
        $W = @DesktopWidth - 170
        $H = @DesktopHeight - 100
        $Form1 = GUICreate($read, $W, $H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    EndIf
    $getz = WinGetClientSize($Form1)
    $get2 = ($getz[0] * .38)
    $get2b = ($getz[1] * .93)
    $getL = StringLen($get2)
    $getLb = StringLen($get2b)
    $get3 = StringInStr($get2, ".")
    If $get3 = 0 Then $get3 = $get2
    $get3b = StringInStr($get2b, ".")
    If $get3b = 0 Then $get3b = $get2b
    $lenth = ($getL - $get3)
    $lenthb = ($getLb - $get3b)
    $ans = StringTrimRight($get2, $lenth + 1)
    $ansb = StringTrimRight($get2b, $lenthb + 1)
    $Obj = _IECreateEmbedded ()
    $browser = GUICtrlCreateObj ($Obj, 8, 8, $W - 20, $H - 70)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    _IENavigate ($Obj, 'about:blank')
    $oDoc = _IEDocGetObj ($Obj)
    $oDoc.body.style.overflow = "auto"
    $oDoc.body.style.margin = "0px"
    $oDoc.body.style.padding = "0px"
    If $inir_1 = "Normal" Or "Large" Or "Supersize" Then $xx = 0
    If $inir_1 = "Small" Then $xx = -15
    $button_6 = GUICtrlCreateButton("End Game", $ans, $ansb + $xx, 80, 30)
    $drop_down_10 = GUICtrlCreateCombo("", $ans + 90, $ansb + ($xx + 4), 80, 20)
    GUICtrlSetData($drop_down_10, "Show All|No Border|No Scale", $inir_2)
    GUISetState(@SW_SHOW)
    $flash1 = @ScriptDir & "\games\" & $selection
    $sHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    $sHTML &= 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'
    $sHTML &= '<embed id=flashy src="'&$flash1&'"'
    $sHTML &= 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
    $sHTML &= 'type="application/x-shockwave-flash" '
    $sHTML &= 'width="100%" height="100%"></embed>' 
    Sleep(50)   
    $Obj1 = _IEGetObjByName ($Obj, "flashy")
    If $inir_1 = "Show All" Then $Obj1.ScaleMode = 0
    If $inir_1 = "No Border" Then $Obj1.ScaleMode = 1
    If $inir_1 = "No Scale" Then $Obj1.ScaleMode = 3
    _IEBodyWriteHTML ($Obj, $sHTML) 
    loadswf($flash1)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $dataread = GUICtrlRead($drop_down_10)
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "game", $read, $dataread)
                GUIDelete($Form1)
                ExitLoop
            Case $button_6
                $dataread = GUICtrlRead($drop_down_10)
                IniWrite(@ScriptDir & "\bin\Fconfig.ini", "game", $read, $dataread)
                GUIDelete($Form1)
                ExitLoop
            Case $drop_down_10
                $dataread = GUICtrlRead($drop_down_10)
                If $dataread = "Show All" Then $Obj1.ScaleMode = 0
                If $dataread = "No Border" Then $Obj1.ScaleMode = 1
                If $dataread = "No Scale" Then $Obj1.ScaleMode = 3
        EndSwitch
    WEnd
EndFunc   ;==>_viewer

func loadswf($filename)
    if stringlen($filename) = 0 then
        msgbox(16,"Flashy","No flash file specified. Associate SWFs with Flashy, or drop one onto the blank window")
        Return
    EndIf
    if stringright($filename,4) <> ".swf" then
        msgbox(16,"Flashy - Error","Dude, that's not a SWF.")
        Return
    EndIf   
    $flash = _IEGetObjByName ($Obj, "flashy")
    $flash.Movie = $filename
    winsettitle($gui,"","Flashy - "&$filename)
    $title = "Flashy - "&$filename
EndFunc
Link to comment
Share on other sites

Works fairly well. Some issues:

1. When you first start it, there is no default Size, and so it shows it in a tiny little window in the top left, and you have to force it closed. I'd recommend setting a default Size if there is no Ini.

2. Changing the size drop down size prior to launching the game doesn't seem to have an effect.

3. Changing the size while running a game throws an error:

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

AutoIt Error

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

Line 138 (File "VollyFlashy.au3"):

If $dataread = "No Border" Then $Obj1.ScaleMode = 1

If $dataread = "No Border" Then $Obj1^ ERROR

Error: Variable must be of type "Object".

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

OK

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

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

I've noticed the error also when I attempt to change size. I took that out, and have it set to a default. Strange, it should make a ini with the default setting if one doesn't exist. I will have to check that.

I asked in a separate thread, and I will remove that post for this one - How does one reliably grab the current url from Firefox? I wanted to add support for that for the flash grabber, but I have no reliable method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...