ASP.NET - Play a flv using asp.net with c# - Asked By Caleb 05 on 21-Sep-09 06:40 AM

Hi frnd's..

can anyone aid me how to play a  flv file using asp.net with c#.Im having no of flv files in a folder i want to play these files by passing their file name.Awaiting for ur reply experts..

Tks in Adv...

Caleb05...

Play a flv using asp.net - Sagar P replied to Caleb 05 on 21-Sep-09 06:49 AM

First off all add the FlashControl.dll and use this function s follows:

public string mediaPath1(object sURL)
{
string str = ("UploadFile/flvplayer.swf?file=video1.flv&image=UploadFile/pics/ThumbnailImg1.jpg");

return ResolveUrl("UploadFile/flvplayer.swf?file=video1.flv&image=UploadFile/pics/ThumbnailImg1.jpg");
}

and use this method on the .aspx page like this

<object style="z-index: 1; position: relative" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"

id="Object1" align="middle" height="160" width="190" class="alloutlineborder">

<param name="movie" value="<%#mediaPath1(Container.DataItem) %>">
<param name="quality" value="high">
<param name="bgcolor" value="#ffffff">
<param name="wmode" value="transparent" />

<embed wmode="transparent" src="<%#mediaPath1(Container.DataItem) %>" quality="high" bgcolor="white" name="lecteur" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" height="160" width="190" />

</object>

Also go thr these links for more help;

http://www.c-sharpcorner.com/UploadFile/scottlysle/FlashPlayerCustomControl12042006230129PM/FlashPlayerCustomControl.aspx

http://dotnet-magic.blogspot.com/2008/10/flash-embeded-in-aspnet-flash-movies-in.html

http://bytes.com/topic/c-sharp/answers/704518-playing-flv-file

you can use tab in HTML - Venkat K replied to Caleb 05 on 21-Sep-09 07:25 AM

HTML Code ::

<object type="application/x-shockwave-flash" width="400" height="350"
 
wmode="transparent" data="flvplayer.swf?file=**vid location**&autoStart=true">
 
<param name="movie" value="flvplayer.swf?file=**vid location**&autoStart=true" />
 
<param name="wmode" value="transparent" />
 
</object>


Solution 2 ::

You can try the following  JW FLV Media Player, it's an open source FLV player written in Flash.

http://www.longtailvideo.com/players/jw-flv-player/

Thanks,

Reply - Deepak Sonawane replied to Caleb 05 on 21-Sep-09 07:25 AM

Hi,

Do following things:

1. Open IIS Manager on the server
2. Expand the Local Computer Server.
3. Examine the 'Properties' of the local server
4. Select the MIME Types tab.
5. Click the 'New' button and enter the following:
* Associated Extension box: .FLV
* MIME Type box: flv-application/octet-stream
6. Click Ok and restart IIS.

Use this code:

There are a two basic steps when placing Flash application to web page:

- First, declare and initiate a Flash object

- Second, set properties of object according to your needs.

You can do this on two different ways, with static HTML tags <OBJECT > and <EMBED>, or by using a JavaScript. With static HTML your code could look something like this:

<object width="640" height="480">
<param name="movie" value="player.swf" />
<embed src="player.swf" width="640" height="480" />
</embed>
</object>


We need both <object > and <embed > tags to get browser compatibility. Internet Explorer uses <object> tag, but Firefox and Netscape can't see it and recognize just <embed>. We set parameters by using <param > tags, and inside <embed > tag. Code example above have added parameter name "movie" and value "player.swf". You can add any other parameter on the same way. Complete list of supported parameters for JW FLV Player you can see at their Flash vars page.

There is a problem with static HTML if visitors access with Internet Explorer. Flash application would not start until visitor clicks on it. If you just place a cursor over a movie you'll see an ugly border. Common way to avoid need to click every time when page load is to initiate Flash player with JavaScript. JavaScript code for starting Flash movie could look like this:

<p id='preview'>The player will show in this paragraph</p>
 
<script type='text/javascript' src='swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('player.swf','player','400','300','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=video.flv');
s1.write('preview');
</script>

bye

Error in SWFObject - Caleb 05 replied to Venkat K on 21-Sep-09 08:30 AM
Hello frnd...

Now Im using  JW FLV Media Player,its working fine.Im have folder named as FLVVideos inside that im having a flv files when i play first file name as 1.flv its playing but when i play anothe file 18.flv its showing an error as like this in that player

Kindly reply me...Awaiting for ur reply Experts....

Tks in Adv...

Caleb05....
RE - Ravenet Rasaiyah replied to Caleb 05 on 21-Sep-09 09:21 AM
Hi

It's path issues, you need give the file path like this way

http://forums.asp.net/t/1170655.aspx

thank you
http://www.codegain.com