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!
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.
Notice there is no active X pop up.
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>
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
http://blog.deconcept.com/swfobject/swfobject.js
ASKER
Here is a picture of what comes out after I run the page.
flashnotworking.jpg
flashnotworking.jpg
ASKER
Here is the code that I put into the asp.net/html file:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.v b" 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.j s"></scrip t>
<title></title>
</head>
<body style="background-color:Bl ack;">
<form id="form1" runat="server">
<div id="flashcontent"></div>
<script type="text/javascript">
var so = new SWFObject("mcslickvideopla yer4.swf", "mcslickvideoplayer4", "720", "480", "9", "#FFFFFF");
so.write("flashcontent");
</script>
</form>
</body>
</html>
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.v
<!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.j
<title></title>
</head>
<body style="background-color:Bl
<form id="form1" runat="server">
<div id="flashcontent"></div>
<script type="text/javascript">
var so = new SWFObject("mcslickvideopla
so.write("flashcontent");
</script>
</form>
</body>
</html>
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.
Not swfobject_source
Download swfobject.js from here: http://blog.deconcept.com/swfobject/swfobject.js
Just right click Save As to your JS folder.
ASKER
OK, the error I got was "Object doesn't support this action". What does that mean?
can you paste your html?
ASKER
Sure. I will paste my html on my new html page that I am testing it with.
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"></sc ript>
</head>
<body>
<div id="flashcontent"></div>
<script type="text/javascript">
var so = new swfobject("mcslickvideopla yer4.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
so.write("flashcontent");
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="js/swfobject.js"></sc
</head>
<body>
<div id="flashcontent"></div>
<script type="text/javascript">
var so = new swfobject("mcslickvideopla
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("mcslickvideopla yer4.swf", "MyFlash", "300", "300", "9", "#FFFFFF");
so.write("flashcontent");
</script>
<script type="text/javascript">
var so = new SWFObject("mcslickvideopla
so.write("flashcontent");
</script>
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?
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.
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.SWFObj ect;
The only "swfobject" I can find is on the first line, and that's part of the URL to download it.
var SWFObject=deconcept.SWFObj
The only "swfobject" I can find is on the first line, and that's part of the URL to download it.
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("mcslickvideopla yer4.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
var so = new SWFObject("mcslickvideopla
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.
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
http://skydrive.live.com
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
http://uploading.com/files/6ZY71R3M/MCSlick.zip.html
Ok, first error.
<script type="text/javascript" src="js/swfobject_source.j s"></scrip t>
should be
<script type="text/javascript" src="js/swfobject.js"></sc ript>
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
<script type="text/javascript" src="js/swfobject_source.j
should be
<script type="text/javascript" src="js/swfobject.js"></sc
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\MCSl ick\video\ comingsoon mcslick4.m p4.
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.
SecurityError: Error #2148: SWF file http://localhost:52398/MCSlick/mcslickvideoplayer4.swf cannot access local resource C:\Users\xxxxxx\Documents\
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.
ASKER
Sorry about that. I'm going to be sending or uploading the Flash file momentarily.
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
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
http://cid-4ac4722874deb647.skydrive.live.com/self.aspx/Web/MCSlick.zip
ASKER
You are amazing!! What ever did you do? That is awesome that you got it to work!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!