我在做一个多媒体数据库时,出现了一个比较麻烦的问题,问过一些人到现在都还没解决,眼看毕业设计就快结束了,我真的都快给急死了。
我用的是paradox做数据库,图片和AVI文件都用的是BLOB格式,存储问题已经都解决了。现在就是要把数据库中AVI文件字段的AVI文件释放出来,并把这个文件用mediaplayer播放,我想过生成零时文件,没做成,后面又听从别人的意见把AVI字段的AVI文件用流式对象保存到硬盘上播放,但是现在却不能创建文件,代码如下忘指教!!!!procedure TForm1.FormActivate(Sender:TObject) ;
begin
Form2.ShowModal; // ÏÔʾÈí¼þ·âÃæ
end ;procedure TForm1.N87Click(Sender: TObject);
varaa:tmemorystream;
begin
form3.showmodal;
if form3.ModalResult=mrok then
begin
table1.Open;
table1.AppendRecord([form3.Edit1.Text,form3.Edit2.Text,form3.Edit3.Text,form3.image1.Picture,nil]);
aa:=tmemorystream.Create;
aa.LoadFromFile(form3.FileListBox1.FileName);
table1.Open;
table1.Edit;
(table1.FieldByName('AVIÎļþ')as tblobfield).LoadFromStream(aa);
end;
end;
procedure TForm1.N88Click(Sender: TObject);
begin
if application.MessageBox('ÊÇ·ñɾ³ýµ±Ç°¼Ç¼£¿','ɾ³ýÈ·ÈÏ',
mb_okcancel)=idok then
table1.Delete;end;procedure TForm1.N89Click(Sender: TObject);
begin
if table1.State=dsbrowse then table1.Edit;
table1.Post;
end;procedure TForm1.N80Click(Sender: TObject);
begin
aboutbox.ShowModal;
end;procedure TForm1.DBImage1Click(Sender: TObject);
var
filestream:tmemorystream ;
begin
filestream:=tmemorystream.create;
(table1.fieldbyname('AVIÎļþ') as tblobfield).savetostream(filestream);
filestream.savetofile('d:\a.avi');
mediaplayer1.FileName:='d:\a.avi';
mediaplayer1.Open;
mediaplayer1.Play;
filestream.free;
if mediaplayer1.Mode=mpstopped then
begin
mediaplayer1.Free;
deletefile('d:\a.avi');
end; end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if mediaplayer1.Mode=mpplaying then
begin
form1.ScrollBar1.Position:=form1.MediaPlayer1.Position;
end;
end;end.
我用的是paradox做数据库,图片和AVI文件都用的是BLOB格式,存储问题已经都解决了。现在就是要把数据库中AVI文件字段的AVI文件释放出来,并把这个文件用mediaplayer播放,我想过生成零时文件,没做成,后面又听从别人的意见把AVI字段的AVI文件用流式对象保存到硬盘上播放,但是现在却不能创建文件,代码如下忘指教!!!!procedure TForm1.FormActivate(Sender:TObject) ;
begin
Form2.ShowModal; // ÏÔʾÈí¼þ·âÃæ
end ;procedure TForm1.N87Click(Sender: TObject);
varaa:tmemorystream;
begin
form3.showmodal;
if form3.ModalResult=mrok then
begin
table1.Open;
table1.AppendRecord([form3.Edit1.Text,form3.Edit2.Text,form3.Edit3.Text,form3.image1.Picture,nil]);
aa:=tmemorystream.Create;
aa.LoadFromFile(form3.FileListBox1.FileName);
table1.Open;
table1.Edit;
(table1.FieldByName('AVIÎļþ')as tblobfield).LoadFromStream(aa);
end;
end;
procedure TForm1.N88Click(Sender: TObject);
begin
if application.MessageBox('ÊÇ·ñɾ³ýµ±Ç°¼Ç¼£¿','ɾ³ýÈ·ÈÏ',
mb_okcancel)=idok then
table1.Delete;end;procedure TForm1.N89Click(Sender: TObject);
begin
if table1.State=dsbrowse then table1.Edit;
table1.Post;
end;procedure TForm1.N80Click(Sender: TObject);
begin
aboutbox.ShowModal;
end;procedure TForm1.DBImage1Click(Sender: TObject);
var
filestream:tmemorystream ;
begin
filestream:=tmemorystream.create;
(table1.fieldbyname('AVIÎļþ') as tblobfield).savetostream(filestream);
filestream.savetofile('d:\a.avi');
mediaplayer1.FileName:='d:\a.avi';
mediaplayer1.Open;
mediaplayer1.Play;
filestream.free;
if mediaplayer1.Mode=mpstopped then
begin
mediaplayer1.Free;
deletefile('d:\a.avi');
end; end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if mediaplayer1.Mode=mpplaying then
begin
form1.ScrollBar1.Position:=form1.MediaPlayer1.Position;
end;
end;end.
解决方案 »
- 如何进行进程间的通讯???
- 高手们这儿有大问题了!有难度,高手!!!高手!!!请进
- ★★★如何得到网上图片的高宽?★★★
- 窗体间ADOQuery调用问题?
- Webbrowser控件问题
- 用这种方法将报表文件保存在数据库中怎么不行?请看:
- 请问大家如何防止DEDE的,我发现许多软件没有进行压缩也无法进行DEDE反编译,通常只能进行到一半
- 高分求救请问带参数的模糊查询怎么写
- 先谢谢^_^,不过还是有一个问题,怎么设置主从表?或者怎么设置明细表?是在delphi里面还是在数据库里面啊?谢谢^_^
- DELPHI里那个语句的功能和vb里的raiseevent一样
- 散分!!第一个程序在天空提交通过!!
- 我想屏蔽系统默认的TAB键的功能来在我的组件中重新定义它,请高手指点。
procedure TForm1.N87Click(Sender: TObject);
varaa:tmemorystream;
begin
form3.showmodal;
if form3.ModalResult=mrok then
begin
table1.Open;
table1.AppendRecord([form3.Edit1.Text,form3.Edit2.Text,form3.Edit3.Text,form3.image1.Picture,nil]);
table1.close; //修改
aa:=tmemorystream.Create;
aa.LoadFromFile(form3.FileListBox1.FileName);
table1.Open; //如果不用上面修改的语句,把这句删除。
table1.Edit;
(table1.FieldByName('AVIÎļþ')as tblobfield).LoadFromStream(aa);
table1.post; //再添加上这一句
end;
end;
var
filestream:tmemorystream ;
begin
filestream:=tmemorystream.create;
(table1.fieldbyname('AVIÎļþ') as tblobfield).savetostream(filestream);
filestream.savetofile('d:\a.avi');
mediaplayer1.FileName:='d:\a.avi';
mediaplayer1.Open;
mediaplayer1.Play;
filestream.free;
if mediaplayer1.Mode=mpstopped then
begin
mediaplayer1.Free;
deletefile('d:\a.avi');
end; end;