Search code examples
flashcefsharp

Cefsharp doesn't load online flash games


I'm creating a personal app that can run any flash games both online and offline. I've been using CefSharp v75.1.143 with Pepperflash plugin. I tried different offline flash games and it worked as intended. But when I tried to play an online flash game, specifically Adventure Quest Worlds, the game gets stuck at 100%. I can't find out the cause because debug.log doesn't show any error at all.

The code that I've been using is:

private void InitializeChromium()
        {
            CefSettings settings = new CefSettings();
            string PepPath = Path.Combine(Directory.GetCurrentDirectory(), @"resources\plugins\pepflashplayer.dll");
            string PepVer = "29.0.0.171";

            settings.CefCommandLineArgs.Add("ppapi-flash-path", PepPath);
            settings.CefCommandLineArgs.Add("ppapi-flash-version", PepVer);
            settings.CefCommandLineArgs["plugin-policy"] = "allow";

            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
            chromeBrowser = new ChromiumWebBrowser(@"aq.com/game"); //The game that I'm testing

            Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;

        }

I tried changing pepflashplayer to an older version but it doesn't work. I also tried adding settings.CefCommandLineArgs.Add("disable-web-security", "1"); and settings.CefCommandLineArgs.Add("allow-file-acccess-from-files", "1"); but still gets the same error.

Is there something wrong with my code?


Solution

  • Finally got it working. The reason why that happens is because Flash/PepperFlash doesn't trust the swf file, causing for it to block all incoming/outgoing connections.

    To make it recognize as trusted by flash, you need to place a text (.txt) or config (.cfg) file in C:\Users\{USER}\AppData\Roaming\Macromedia\Flash Player\#Security\FlashPlayerTrust (directory depends on your os and/or flash version). Inside the text contains a path where the directory of the swf is located. It can be also a path to the file itself.

    For more detailed explanation, you can refer here.