Link to home
Start Free TrialLog in
Avatar of VBBRett
VBBRett

asked on

How do you play a Flash file in ASP.net?

I am trying to play a Flash video that has an mp4 source in an ASP.net page without running into that ActiveX problem that stops you from running anything until you click the top of the page to accept the ActiveX control.  Is there a way I can embed the code in ASP.net/HTML without any Javascript?  I got the video to work on it's own but I need it to work with my web page.  Thanks!
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

As I mentioned in the other question, all you need to do is use the SWFObject, or Flash Object, which bypasses the activeX popup.
Here is an example: http://blog.deconcept.com/swfobject/swfobject.html

Notice there is no active X pop up.
Avatar of VBBRett
VBBRett

ASKER

Would you be able to spell out the code that I should add to my html file or asp.net file?
Sure.
<html>
  <head>
     <script type="text/javascript" src="swfobject.js"></script>
  </head>
  
  <body>
    <div id="flashcontent"></div>
 
    <script type="text/javascript">
	var so = new SWFObject("MyFlashMovie.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
        so.write("flashcontent");
    </script>
 
  </body>
</html>

Open in new window

You can download the swfobject.js from here.  Just save it in the same folder as your html pages.

http://blog.deconcept.com/swfobject/swfobject.js
Avatar of VBBRett

ASKER

Here is a picture of what comes out after I run the page.
flashnotworking.jpg
Avatar of VBBRett

ASKER

Here is the code that I put into the asp.net/html file:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="MCSlick._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script type="text/javascript" src="js/swfobject_source.js"></script>
    <title></title>
</head>
<body style="background-color:Black;">
    <form id="form1" runat="server">
    <div id="flashcontent"></div>
 
    <script type="text/javascript">
        var so = new SWFObject("mcslickvideoplayer4.swf", "mcslickvideoplayer4", "720", "480", "9", "#FFFFFF");
        so.write("flashcontent");
    </script>

    </form>
</body>
</html>
Avatar of VBBRett

ASKER

It is not finding the SWFObject.  The SWFObject is undefined.
That should be js/swfobject.js

Not swfobject_source

Download swfobject.js from here: http://blog.deconcept.com/swfobject/swfobject.js

Just right click Save As to your JS folder.
Avatar of VBBRett

ASKER

OK, the error I got was "Object doesn't support this action".  What does that mean?
can you paste your html?
Avatar of VBBRett

ASKER

Sure.  I will paste my html on my new html page that I am testing it with.
Avatar of VBBRett

ASKER

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <title></title>
     <script type="text/javascript" src="js/swfobject.js"></script>
  </head>
 
  <body>
    <div id="flashcontent"></div>
 
    <script type="text/javascript">      
      var so = new swfobject("mcslickvideoplayer4.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
      so.write("flashcontent");
       
    </script>
 
  </body>
</html>
JavaScript is Case Sensitive. So it doesn't know what swfobject is.

<script type="text/javascript">
        var so = new SWFObject("mcslickvideoplayer4.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
        so.write("flashcontent");
</script>
Avatar of VBBRett

ASKER

Any clue as to why it is not working for me?
Did you fix the case sensitive issue that I mentioned in my last post?  Do you have the page uploaded somewhere so I can look at it if that didn't fix it?
Avatar of VBBRett

ASKER

Actually, swfobject is how it is supposed to be showed or displayed.  SWFObject was not recognized.  When the Javascript file was opened, I saw that SWFObject was spelled swfobject as opposed to SWFObject.
Avatar of VBBRett

ASKER

I'm not sure if you saw my page output, but I have an output that has a white box where the video should be.
I'm not sure which javascript file you are looking at, the link I gave you has

var SWFObject=deconcept.SWFObject;

The only "swfobject" I can find is on the first line, and that's part of the URL to download it.
Avatar of VBBRett

ASKER

Can you post the link again?  THis is not working out for me.  My Flash file is not working and all I want to play is an mp4 file through flash.  I tried to use Dreamweaver to play the file or put code in and I still get the same thing as before, a white box.  Here is the code I used.  Is this using an older version of Flash and am I supposed to update the code to a newer flash?  Would you be able to just submit for me a html page that works for you?  My swf file is called mcslickvideoplayer4.swf and my mp4 file is called comingsoonmcslick4.mp4.  Why this is not working out for me is beyond me.  I thought this was supposed to be simple and I was able to make Flash work for me before but I don't understand why it won't play.
You can modify what version of flash is required with the SWFObject declaration.

var so = new SWFObject("mcslickvideoplayer4.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
mcslickvideoplayer4.swf = flash file to load
MyFlash = ID
300 = width
300 = height
9 = minimum flash version 9
#FFFFFF = background color white

Here is a screen capture of what my source code and directory structure, everything is working fine for me with it.

http://screencast.com/t/2dfLtHy9dn
If you could zip and upload your files somewhere, I could download them and see what is wrong if you are still having problems.
Avatar of VBBRett

ASKER

Sure, I will send you the files.  Give me a second.  Is there a place I can upload a file that is larger then 7 megs but less then 8 megs?
Yeah, if you have a windows live account, just use the skydrive, put it in the public folder and then give me the link.

http://skydrive.live.com
Avatar of VBBRett

ASKER

Here is a link.  By the way, ignore alot of the files.  Focus on WebForm.aspx.  Thanks.  Here is the link:

http://uploading.com/files/6ZY71R3M/MCSlick.zip.html
Ok, first error.

<script type="text/javascript" src="js/swfobject_source.js"></script>

should be

<script type="text/javascript" src="js/swfobject.js"></script>

Second problem, the swfobject.js file that you have is all messed up, download this one, right click and hit Save As... http://blog.deconcept.com/swfobject/swfobject.js
Flash errors:
SecurityError: Error #2148: SWF file http://localhost:52398/MCSlick/mcslickvideoplayer4.swf cannot access local resource C:\Users\xxxxxx\Documents\Visual Studio 2008\Projects\MCSlick\MCSlick\video\comingsoonmcslick4.mp4.

You need to put comingsoonmcslick4.mp4 for the source, not the entire file path like that, or remove that code so you can just use the FLV Playback control.

Error #2044: Unhandled skinError:. text=[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035: URL Not Found. URL: SkinOverPlaySeekMute.swf"

You need to have the file SkinOverPlaySeekMute.swf in the same directory as your flash file, so it can load the video player skin.
Also, you didn't include the FLA file so I can't fix anything in the flash.
Avatar of VBBRett

ASKER

Sorry about that.  I'm going to be sending or uploading the Flash file momentarily.
Avatar of VBBRett

ASKER

Hi aibusinesssolutions, here is the FLA file.  Please let me know what needs to be changed in order for this whole thing to work out.

http://uploading.com/files/9LTH0D4N/mcslickvideoplayer4.zip.html
Ok, I got it all working on my end and zipped it all up. Here you go:

http://cid-4ac4722874deb647.skydrive.live.com/self.aspx/Web/MCSlick.zip
Avatar of VBBRett

ASKER

You are amazing!!  What ever did you do?  That is awesome that you got it to work!!!
ASKER CERTIFIED SOLUTION
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VBBRett

ASKER

aibusinesssolutions, thank you very much for your help.  I wish I could reward you with more but 500 points is all I have to give.  Thank you very very much!