从BLOB获取视频并播放该视频

时间:2013-11-25 19:20:29

标签: c# sql oracle11g

我正在研究oracle 11g。我创建了一个有3列的表,SQL for create table是

create table blobvideo(fileid int,filename varchar2(100), filedata blob);

我在该表中插入视频的代码是

        FileInfo fi = new FileInfo("C:\videoPath.mp4");
        FileStream fs = new FileStream(videoFilePath, FileMode.Open, FileAccess.Read);
        byte[] fileToByte = new byte[fs.Length];
        fs.Read(fileToByte, 0, Convert.ToInt32(fs.Length));

        String strSQL = "INSERT INTO blobvideo (FileId,filename,FILEDATA) VALUES (1,'" + fi.FullName + "',:TEXT_DATA)";

        OracleParameter parmData = new OracleParameter();
        parmData.Direction = ParameterDirection.Input;
        parmData.OracleDbType = OracleDbType.Blob;
        parmData.ParameterName = "TEXT_DATA";
        parmData.Value = fileToByte;

        OracleCommand cm = new OracleCommand();
        cm.Connection = myConnection;
        cm.Parameters.Add(parmData);
        cm.CommandText = strSQL;
        myConnection.Open();
        cm.ExecuteNonQuery();
        myConnection.Close();

获取BLOB的代码是

        OracleCommand ocmd1 = new OracleCommand("select * from blobfile ", myConnection);
        myConnection.Open();
        OracleDataReader rds = ocmd.ExecuteReader();
        rds.Read();
        OracleBlob newBlob = rds.GetOracleBlob(2);

插入效果很好,但我的问题是如何才能获得该视频以及如何在Windows Media Player或vlc或任何其他使用C#的视频播放器中播放该视频。

0 个答案:

没有答案