c# - Building a YouTube-like Video Playing Site Using ASP.NET Techniques -
hi want create simple site allow users upload , view video. i'm using asp:literal:literal1 tool insert flash player
after necessary coding realize user can find particular video url (eg "play.aspx?id=<%#eval("id") %>" , problem when user gets playing page shows no player how fix it?please me...
it indicates can find url request cant display player
my code:
public partial class play : system.web.ui.page { public class operatemethod { public operatemethod() { } // ▲show flash player , can play video public static string getflashtext(string url) { url = "player.swf?filename=" + url; string str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='452' height='360' id='index' name='index'><param name='allowscriptaccess' value='always' /><param name='movie' value='" + url + "'><embed src='" + url + "' id='index1' name='index1' type='application/x-shockwave-flash' swliveconnect=true allowscriptaccess='always' width='452' height='360'></embed></object>"; return str; } } public class operatedata { public operatedata() { } public static sqlconnection createcon() { sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["databaseconnectionstring"].tostring()); return con; } public static sqldatareader getrow(string sql) { sqlconnection con = createcon(); con.open(); sqlcommand com = new sqlcommand(sql, con); sqldatareader sdr = com.executereader(); return sdr; } } public string name; //publisher public string videotittle; //video name public string videocontent; //content public string videotype; //videotype protected void page_load(object sender, eventargs e) { if (!ispostback) { //判断用户是否登录 if (session["username"] == null) { //未登录显示登录panel panellogin.visible = true; //隐藏欢迎panel panelhello.visible = false; } else { //hide login pannel panellogin.visible = false; //show hello pannel panelhello.visible = true; //show login user name lbeusername.text = session["username"].tostring(); } } //play video videoinfo(); } protected void videoinfo() { //set script query detail info string sql = "select * videoinfo id =" + request["id"]; sqldatareader sdr = operatedata.getrow(sql); sdr.read(); //obtain video path string link = sdr["videopath"].tostring(); //get video hit rate playsum = sdr["playsum"].tostring(); //get number of "likes" flower = sdr["flower"].tostring(); //get number of "dislikes" tile = sdr["title"].tostring(); //obtain video publish date videodate = sdr["videodate"].tostring(); //get name of publisher name = sdr["username"].tostring(); //get video tittle videotittle = sdr["videotittle"].tostring(); //obtain video content videocontent = sdr ["videocontent"].tostring(); //obtain video type videotype = sdr ["videotype"].tostring(); //judge whether path starts 'http://' if (!link.startswith("http://")) { //obtain absolute path string sss = request.url.absoluteuri; //locate location of "play.aspx" @ string int idx = sss.indexof("play.aspx"); //get specified string sss = sss.substring(0,idx); link = sss + link; } //show player , play video this.literal1.text = operatemethod.getflashtext(link); } }
}
Comments
Post a Comment