Reputation: 1106
I am trying to embed a video on page with object but my problem is that source is in database so i cant use url. What are my options? Given that I have never worked with the videos in ASP.NET
Upvotes: 0
Views: 3970
Reputation: 5213
Assuming you are using a flash video player, you first need to make sure the flash is accepting variables. If it is not already, you need to do some research on "flashvars" as you will need them to pass the source of the video to the flash player.
Once you have your flash video player setup to accept the source in a flashvar, you need to construct your .net page to pass the source. The way I normally do it is to declare a public property on your code behind and assign the source to that (however you need to whether it is by querystring, sessions, etc). You'll then read that public property into your flashvars statement on the embed/object tag. Like this...
Create public property in code behind and assign value:
public string PathToVideo { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
//--- replace with your path
PathToVideo = Page.ResolveClientUrl("~/videos/filename.flv");
}
Then read it on the front side:
<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player"
width="560" height="400">
<param name="movie" value="../js/player.swf" />
<param name="wmode" value="opaque" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="file=<%= PathToVideo %>&image=<%= PathToVideo.ToLower().Replace("videos/","videos/thumbs/").Replace(".flv",".jpg") %>" />
<embed type="application/x-shockwave-flash" id="player2" name="player2" src="../js/player.swf"
wmode="opaque" width="560" height="400" allowscriptaccess="always" allowfullscreen="true"
flashvars="file=<%= PathToVideo %>&image=<%= PathToVideo.ToLower().Replace("videos/","videos/thumbs/").Replace(".flv",".jpg") %>" />
</object>
On my embed tag, you notice I pass to the flashvars, the video source and a thumbnail source. This way, while I wait for them to press play or the video stops, it shows the thumbnail of the first frame.
Good Luck!
Upvotes: 1