Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Flash in WPF

Tags:

c#

flash

wpf

xaml

i am trying to run a .swf file in my WPF application, i have created a html page and in that i have referenced my .swf file using object tag and then loading that 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>

assigning the source

   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);
        }
    }

The Problem:

when i run the application the warning occurs that ActiveX content is trying to access etc etc and when i allow it nothing appears in my main window the warning keeps on occuring multiple times.

if i run the flash movie in the browser directly it runs just fine.

Regards.

like image 576
John x Avatar asked Sep 30 '11 07:09

John x


1 Answers

  1. I have a flash based clock as a .swf file on my C:\Test\MyClock.swf

  2. I have a htm file at C:\Test\MyHtml.htm

      <embed src=C:\Test\MyClock.swf
             width=200 height=200
             wmode=transparent type=application/x-shockwave-flash>
      </embed>
    
  3. I have web browser control as 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>           
    
  4. On running the app, I see the webbrowser control giving warning as "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options."

  5. I accept the warning by right click and the left click "Allow Blocked Content". A confirmation popup appears to which I say Yes.

  6. I see the Flash based clock.

like image 50
WPF-it Avatar answered Oct 01 '22 12:10

WPF-it