Run Flash in WPF

I try to run a .swf file in my WPF application, I created an html page and in this I referenced my .swf file using the object tag and then loaded this html page in my Main Window

my xaml looks like

 <Window x:Class="sirajflash.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <WebBrowser Name="myBrowser"></WebBrowser> <!--<Frame Name="myframe"/>--> //tried with frame also but no luck </Grid> </Window> 

source assignment

  public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); myBrowser.Source = new Uri(CreateAbsolutePathTo("playflash.htm"), UriKind.Absolute); } private static string CreateAbsolutePathTo(string mediaFile) { return System.IO.Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, mediaFile); } } 

Problem:

when I launch the application, a warning appears that ActiveX content is trying to access, etc. etc., and when I allow it nothing appears in my main window, the warning continues to occur several times.

if I run a flash movie in a browser, it works just fine.

Sincerely.

+6
source share
2 answers
  • I have a flash based watch as a .swf file on my C: \ Test \ MyClock.swf

  • I have an htm file in C: \ Test \ MyHtml.htm

      <embed src=C:\Test\MyClock.swf width=200 height=200 wmode=transparent type=application/x-shockwave-flash> </embed> 
  • I have a web browser control as shown below ...

     <Window x:Class="MyFlashApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <WebBrowser Source="C:\Test\MyHtml.htm"></WebBrowser> </Grid> </Window> 
  • When I launch the application, I see that the web browser control gives a warning like "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options."

  • I accept the warning by right-clicking and left-clicking “Allow Blocked Content”. A confirmation pop-up will appear, which I will say Yes .

  • I see a watch based on Flash.

+4
source

The WebBrowser control can support flash directly. If you don’t need to represent anything in HTML, you can directly specify the path to the flash file.

 myWebBrowser.Source = "C:\Test\MyClock.swf" 

However, you will still receive an IE warning.

0
source

Source: https://habr.com/ru/post/898351/


All Articles