一般会搭建一个多媒体服务器,支持流媒体格式处理。程序或者网站中涉及到的图片、音频和视频等资料会存放在流媒体服务器上,然后可以记录访问其的路径,然后把这个路径存入数据库,在你的应用系统调用时,可以通过路径结合对应的多媒体播放插件就可以实现。
很久以前有一段C++Builder的代码了~~//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "DBClient.hpp"
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SUIDlg"
#pragma resource "*.dfm"
int count=0
bool change = true
TForm1 *Form1
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{
// Video format dialog box.
if (CapDrvCaps.fHasDlgVideoFormat)
{
capDlgVideoFormat(hWndC)
// Are there new image dimensions?
capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS))
SetWindowPos(hWndC, NULL,
0,
0,
CapStatus.uiImageWidth,
CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE)
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N2Click(TObject *Sender)
{
if (CapDrvCaps.fHasDlgVideoSource)
capDlgVideoSource(hWndC)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
if(ADODataSet1->State==1)
ADODataSet1->Close()
ADODataSet1->CommandText="select Class,Number,Name,Sex,Nation,NativePlace,BirthDay from stu_info where Number='"+Stu_Number->Text.Trim()+"'"
try
{
ADODataSet1->Open()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
if(ADODataSet1->RecordCount<1)
{
ADODataSet1->Close()
MessageBox(Handle,"\r\n 错误/非法的学号!\r\n\r\n 请重新填写…… \r\n","出现错误",16)
Stu_Number->SetFocus()
}
else
{
bool have = false
for(int i=0i<=Stu_Number->Items->Count-1i++)
{
if(Stu_Number->Items->Strings[i]==Stu_Number->Text)
{
have=true
break
}
}
if(!have)
Stu_Number->Items->Add(Stu_Number->Text)
//Stu_Number->ItemIndex=Stu_Number->Items->Count-1
Image2->Picture=NULL
TADOQuery *sql = new TADOQuery(this)
sql->Connection = DForm->conn
sql->SQL->Text="select * from stu_photo where Number='"+Stu_Number->Text.Trim()+"'"
try
{
sql->Open()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
if(sql->RecordCount>0)
{
Label11->Visible=false
TADOBlobStream *tmpBStrm=new TADOBlobStream((TBlobField *)(sql->FieldByName("photo")),bmRead)
tmpBStrm->Seek(0,soFromBeginning)
TPicture *pic = new TPicture()
pic->Bitmap->LoadFromStream(tmpBStrm)
Image2->Picture = pic
delete pic
delete tmpBStrm
}
else
{
Label11->Visible=true
}
sql->Close()
delete sql
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
/*Application->ShowMainForm = false
int res=suiPasswordDialog1->ShowModal()
if(res==1)
{
if(!(suiPasswordDialog1->Item1Text=="sctc"&&suiPasswordDialog1->Item2Text=="sctc!@#$%^"))
{
MessageBox(Handle,"错误的用户名和密码!","启动失败",16)
Application->Terminate()
}
else
{
Form1->DoubleBuffered = true
Form1->Show()
}
}
else
{
Application->Terminate()
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
capDriverDisconnect(hWndC)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//count++
//capFileSaveDIB( hWndC,("pic\\temp"+IntToStr(count)+".bmp").c_str())
//Image3->Picture->LoadFromFile("pic\\temp"+IntToStr(count)+".bmp")
capFileSaveDIB( hWndC,"temp.bmp")
Image3->Picture->LoadFromFile("temp.bmp")
DeleteFile("temp.bmp")
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TRect rt(0,0,Image3->Picture->Width,Image3->Picture->Height)
Image3->Canvas->FillRect(rt)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
TPicture *pic = new TPicture()
pic->LoadFromFile(OpenDialog1->FileName)
Image3->Picture = pic
delete pic
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
if(DBText3->Caption!="")
{
Label11->Visible=false
Image2->Picture = Image3->Picture
TADOQuery *sql = new TADOQuery(this)
sql->Connection = DForm->conn
sql->SQL->Text="select * from stu_photo where Number='"+DBText1->Caption+"'"
try
{
sql->Open()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
if(sql->RecordCount>0)
{
TMemoryStream *temp=new TMemoryStream()
Image3->Picture->Bitmap->SaveToStream(temp)
sql->Edit()
sql->FieldByName("ModifyTime")->Value = Now()
((TBlobField *)sql->FieldByName("photo"))->LoadFromStream(temp)
try
{
sql->Post()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
}
else
{
TMemoryStream *temp=new TMemoryStream()
Image3->Picture->Bitmap->SaveToStream(temp)
sql->Append()
sql->FieldByName("Number")->Value = DBText1->Caption
sql->FieldByName("ModifyTime")->Value = Now()
((TBlobField *)sql->FieldByName("photo"))->LoadFromStream(temp)
try
{
sql->Post()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
}
sql->Close()
delete sql
Image2->Picture = Image3->Picture
}
else
{
MessageBox(Handle,"无法保存图片!(请输入学号)","保存图片失败",16)
Stu_Number->SetFocus()
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
TPoint pt
GetCursorPos(&pt)
PopupMenu1->Popup(pt.x,pt.y)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Stu_NumberSelect(TObject *Sender)
{
Button4Click(Sender)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N3Click(TObject *Sender)
{
Form1->hWndC = capCreateCaptureWindow (
(LPSTR) "My Capture Window", // window name if pop-up
WS_CHILD | WS_VISIBLE, // window style
0, 0, 320, 240, // window position and dimensions
(HWND)Form1->Panel1->Handle,//(HWND)Application->Handle,//(HWND) hwndParent,
0)//(int) nID /* child ID */)
//连接设备:
int tag=capDriverConnect(Form1->hWndC,0)
capPreviewRate(Form1->hWndC, 33)// rate, in milliseconds
capPreview(Form1->hWndC, TRUE)// starts preview
//capDlgVideoFormat(Form1->hWndC)
//获取视频驱动相关性能
capDriverGetCaps(Form1->hWndC, &(Form1->CapDrvCaps), sizeof (CAPDRIVERCAPS))
//获取捕获窗口状态
capGetStatus(Form1->hWndC, &(Form1->CapStatus), sizeof (CAPSTATUS))
SetWindowPos(Form1->hWndC, NULL,
0,
0,
Form1->CapStatus.uiImageWidth,
Form1->CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE)
if(tag)
{
Form1->Button1->Enabled=true
Form1->N1->Enabled=true
Form1->N2->Enabled=true
}
else
{
Form1->Button1->Enabled=false
Form1->N1->Enabled=false
Form1->N2->Enabled=false
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N4Click(TObject *Sender)
{
capDriverDisconnect(hWndC)
Button1->Enabled=false
N1->Enabled=false
N2->Enabled=false
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Stu_NumberKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13)
Button4Click(Sender)
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13)
{
if(change)
{
if(ADODataSet1->State==1)
ADODataSet1->Close()
ADODataSet1->CommandText="select Class,Number,Name,Sex,Nation,NativePlace,BirthDay from stu_info where Number='"+Edit1->Text.Trim()+"'"
try
{
ADODataSet1->Open()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
if(ADODataSet1->RecordCount<1)
{
ADODataSet1->Close()
MessageBox(Handle,"\r\n 错误/非法的学号!\r\n\r\n 请重新填写…… \r\n","出现错误",16)
Stu_Number->SetFocus()
}
else
{
Image2->Picture=NULL
TADOQuery *sql = new TADOQuery(this)
sql->Connection = DForm->conn
sql->SQL->Text="select * from stu_photo where Number='"+Edit1->Text.Trim()+"'"
try
{
sql->Open()
}
catch(Exception &Err)
{
MessageBox(Application->Handle,Err.Message.c_str(),"程序运行时错误",16)
}
if(sql->RecordCount>0)
{
Label11->Visible=false
TADOBlobStream *tmpBStrm=new TADOBlobStream((TBlobField *)(sql->FieldByName("photo")),bmRead)
tmpBStrm->Seek(0,soFromBeginning)
TPicture *pic = new TPicture()
pic->Bitmap->LoadFromStream(tmpBStrm)
Image2->Picture = pic
delete pic
delete tmpBStrm
}
else
{
Label11->Visible=true
}
sql->Close()
delete sql
}
change=false
Edit1->Text=""
change=true
Edit1->SetFocus()
}
}
}
//---------------------------------------------------------------------------
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)