// Make sure you run this on a UI thread public static void CheckFlash(Action flashInstalledCallback, Action flashNotInstalledCallback, Action errorCallback) { _flashInstalledCallback = flashInstalledCallback; _flashNotInstalledCallback = flashNotInstalledCallback; _errorCallback = errorCallback; // Read in swfobject. Included locally so this runs without a network connection. System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("AwesomiumCheckFlashChecker.Resources.swfobject.js"); System.IO.StreamReader sr = new System.IO.StreamReader(s); string swfObjectCode = sr.ReadToEnd(); string html = ""; html += "<div id='flashstatus'></div>"; //html += "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'></script>"; html += "<script type='text/javascript'>" + swfObjectCode + "</script>"; html += "<script type='text/javascript'>"; html += "document.getElementById('flashstatus').innerHTML = swfobject.hasFlashPlayerVersion('1') ? 'FLASH INSTALLED' : 'NO FLASH';"; html += "</script>"; try { _checkFlashSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences()); _webView = Awesomium.Core.WebCore.CreateWebView(100, 100, _checkFlashSession, Awesomium.Core.WebViewType.Offscreen); _webView.DocumentReady += new Awesomium.Core.UrlEventHandler(webView_DocumentReady); bool success = _webView.LoadHTML(html); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); } }
public WebBgMusicForm() { this.Opacity = 0; Awesomium.Core.WebPreferences prefs = new Awesomium.Core.WebPreferences(); prefs.FileAccessFromFileURL = true; prefs.UniversalAccessFromFileURL = true; prefs.WebGL = true; string configFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + @"\mute.fm"; Awesomium.Core.WebSession session = Awesomium.Core.WebCore.CreateWebSession(configFolder + @"\Awesomium", prefs); InitializeComponent(); this.webControl1 = new Awesomium.Windows.Forms.WebControl(); this.dockBrowserControl.Controls.Add(this.webControl1); // // webControl1 // this.webControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.webControl1.Location = new System.Drawing.Point(20, 20); this.webControl1.Name = "webControl1"; // TODO: Code generation for 'this.webControl1.NativeView' failed because of Exception 'Invalid Primitive Type: System.IntPtr. Consider using CodeObjectCreateExpression.'. this.webControl1.Size = new System.Drawing.Size(1156, 447); this.webControl1.TabIndex = 3; webControl1.WebSession = session; //this.webControl1. //webBrowser1.ScriptErrorsSuppressed = true; this.TopMost = false; //TODO this.ShowInTaskbar = true; this.Text = MuteFm.Constants.ProgramName + " browser"; mToolStrip.Items.Clear(); this.SuspendLayout(); mVolumeUpDown.Increment = 5; mVolumeUpDown.DecimalPlaces = 1; this.Width = 950; InitPanelHeadersHeight = panelHeaders.Height - 31; //TODO // this.mVolumeTrackBar.Visible = false; // Order here matters. Change UpdateUiForState if this gets changed (a little hacky for now) mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("home.png"), new EventHandler(mHomeToolStripButton_Click)); mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("pin.png"), new EventHandler(mAlwaysOnTopToolStripButton_Click)); mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("unpin.png"), new EventHandler(mNotAlwaysOnTopToolStripButton_Click)); //mToolStrip.Items.Add("Send To Chrome", null, new EventHandler(mAlwaysOnTopToolStripButton_Click)); // TODO: also for other browsers mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("mute.png"), new EventHandler(mMuteButton_Click)); mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("unmute.png"), new EventHandler(mUnmuteButton_Click)); mToolStrip.Items.Add("", WebServer.GetBitmapFromWebServer("stop.png"), new EventHandler(mStopButton_Click)); // TODO: also other operations //mToolStrip.Items.Add("Refresh", null, new EventHandler(mAlwaysOnTopToolStripButton_Click)); // Make this always the last button so that the next fix doesn't have to get changed this.ResumeLayout(); panelToolbar.Width = mToolStrip.Left + mToolStrip.Width + 0; UpdateUiForState(); webControl1.LoadingFrameComplete += new Awesomium.Core.FrameEventHandler(webControl1_LoadingFrameComplete); webControl1.DocumentReady += new Awesomium.Core.UrlEventHandler(webControl1_DocumentReady); this.panelHeaders.Height = InitPanelHeadersHeight; //this.panelCannotHear.Height; this.panelCannotHear.Visible = false; webControl1.AddressChanged += new Awesomium.Core.UrlEventHandler(webControl1_AddressChanged); this.Visible = true; }