winforms - Play video from blob data Oracle using C# -
i have created simple project save blob file data oracle database using c# winform , worked fine. now, wanna play video blob oracle data using c# couldn't. here code:
if (koneksidb.con.state == connectionstate.open) { koneksidb.con.close(); } koneksidb.con.open(); oraclecommand cmd = new oraclecommand(); oracledatareader dr; cmd.commandtext = @"select id,filename, filedata, keterangan, substr(filename, -4)as fileextention latihanfilemanager id = '1' , ispreview = n'1'"; cmd.connection = koneksidb.con; dr = cmd.executereader(); while (dr.read()) { string fileextention = dr["fileextention"].tostring(); //got file extention database switch(fileextention) { case ".pdf": //when blob pdf file worked fine byte[] filebytes = (byte[])dr["filedata"]; system.io.memorystream stream = new system.io.memorystream(filebytes); fmpdfviewer f = new fmpdfviewer(); f.pdfviewer1.loaddocument(stream); //when file .pdf can display preview using pdf viewer in devexpress f.show(); break; case ".mp4": //when blob video string path = ""; //here problem how can play file video blob oracle data fmvideoviewer vd = new fmvideoviewer(); vd.axwindowsmediaplayer1.url = path; vd.axwindowsmediaplayer1.settings.autostart = true; vd.show(); break; } } dr.close();
really need solution, before.
you can save file on disk , play it.
byte[] bytes = (byte[])dr["filedata"]; string name = (string)dr["filename"] + (string)dr["fileextention"]; var path = system.io.path.combine(application.startuppath, name); system.io.file.writeallbytes(path , bytes); this.axwindowsmediaplayer1.url = path; this.axwindowsmediaplayer1.ctlcontrols.play();
you can use application.startuppath
or other path prefer cache files.
after while it's better cleanup cached files.
Comments
Post a Comment