本文介绍了在Asp.Net应用程序中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用此代码上传视频现在我想在Asp页面上播放。 plzz告诉我任何想法或代码.Thnxx .. !! 使用系统; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Web; 使用 System.Web.UI; 使用 System.Web.UI.WebControls; 使用 System.Web.UI.WebControls.WebParts; 使用 System.Web.UI.HtmlControls; 使用 System.Data; 使用 System.Data.SqlClient; 使用 System.Web; public partial class video1:System.Web.UI.Page { protected void Page_Load( object sender,EventArgs e) { } byte []缓冲区; 受保护 void Button1_Click( object sender,EventArgs e) { { String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName)。降低(); byte [] MediaBytes = new byte [FileUpload1.PostedFile.InputStream.Length]; if (FileUpload1.HasFile&& FileUpload1.PostedFile!= null &&& FileUpload1.PostedFile.FileName!= ) { HttpPostedFile file = FileUpload1.PostedFile; buffer = new byte [file.ContentLength]; int bytesReaded = file.InputStream.Read(buffer, 0 ,FileUpload1.PostedFile.ContentLength ); if (bytesReaded > 0 ) { try { SqlConnection conn = new SqlConnection(); conn.ConnectionString = 数据源= DEEPAK-PC\\SQLEXPRESS;初始目录= NewCrackers;用户ID = sa;密码= sasa; conn.Open(); SqlCommand cmd = new SqlCommand ( INSERT INTO Videos(Video,Video_Name,Video_Size)VALUES(@ video,@ videoName,@ videoSize),conn); cmd.Parameters.Add( @ video,SqlDbType.VarBinary,buffer.Length ).Value =缓冲; cmd.Parameters.Add( @ videoName,SqlDbType.NVarChar).Value = FileUpload1.FileName; cmd.Parameters.Add( @ videoSize,SqlDbType.BigInt).Value = file.ContentLength; 使用(conn) { cmd.ExecuteNonQuery(); Label1.Text = 已上传; conn.Close(); } } catch (例外情况) { Label1.Text = ex.Message。的ToString(); } } } else { Label1.Text = 选择有效的视频文件; } } } } 解决方案 下载Flash控件/ silverlight并将其添加到您的工具箱中。 然后指定控件的路径。 下载flashControl 此处 [ ^ ]和silverlight 这里 [ ^ ] 对于Flash播放器: Flash1.MovieURL = Path; Silverlight: MediaPlayer1.MediaSource = 路径; Hii i m uploading video using this code now i want to play this on Asp page.plzz tell me any idea or code..Thnxx..!!using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data;using System.Data.SqlClient;using System.Web;public partial class video1 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } byte[] buffer; protected void Button1_Click(object sender, EventArgs e) { {String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();byte[] MediaBytes = new byte[FileUpload1.PostedFile.InputStream.Length];if (FileUpload1.HasFile && FileUpload1.PostedFile != null&& FileUpload1.PostedFile.FileName != ""){HttpPostedFile file = FileUpload1.PostedFile;buffer = new byte[file.ContentLength];int bytesReaded = file.InputStream.Read(buffer, 0, FileUpload1.PostedFile.ContentLength);if (bytesReaded > 0){try{SqlConnection conn = new SqlConnection();conn.ConnectionString = "Data Source=DEEPAK-PC\\SQLEXPRESS;Initial Catalog=NewCrackers;User ID=sa;Password=sasa";conn.Open();SqlCommand cmd = new SqlCommand("INSERT INTO Videos (Video, Video_Name, Video_Size) VALUES (@video, @videoName, @videoSize)", conn);cmd.Parameters.Add("@video", SqlDbType.VarBinary, buffer.Length).Value = buffer;cmd.Parameters.Add("@videoName", SqlDbType.NVarChar).Value = FileUpload1.FileName;cmd.Parameters.Add("@videoSize", SqlDbType.BigInt).Value = file.ContentLength;using (conn){cmd.ExecuteNonQuery();Label1.Text = " uploaded ";conn.Close();}}catch (Exception ex){Label1.Text = ex.Message.ToString();}}}else{Label1.Text = "Choose a valid video file";}}}} 解决方案 这篇关于在Asp.Net应用程序中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-04 22:48