首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用DSPack循环播放视频?

如何使用DSPack循环播放视频?
EN

Stack Overflow用户
提问于 2013-01-06 05:51:43
回答 1查看 1.2K关注 0票数 0

我有一个非常简单的程序,它使用Delphi2010中的DSPack。我有一个带有TFilterGraph和TVideoWindow的表单。视频可以很好地播放和渲染。我似乎想不出当视频结束时如何让它循环回到开头。

如何使用DSPack让视频自动循环?

代码

代码语言:javascript
复制
unit Unit21;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DSPack, ExtCtrls;

type
  TForm21 = class(TForm)
    FilterGraph1: TFilterGraph;
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    Button2: TButton;
    Panel1: TPanel;
    VideoWindow1: TVideoWindow;
    Panel2: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form21: TForm21;

implementation

{$R *.dfm}

procedure TForm21.Button1Click(Sender: TObject);
begin
  OpenDialog1.InitialDir := ExtractFilePath(ParamStr(0));
  if OpenDialog1.Execute then
  begin
    if not FilterGraph1.Active then FilterGraph1.Active:= True;
    VideoWindow1.FilterGraph:= FilterGraph1;
    FilterGraph1.RenderFile(OpenDialog1.Filename);
    FilterGraph1.Play;
  end;
end;

procedure TForm21.Button2Click(Sender: TObject);
begin
  FilterGraph1.Stop;
end;

procedure TForm21.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  FilterGraph1.ClearGraph;
  FilterGraph1.Active:= False;
end;

end.

DFM

代码语言:javascript
复制
object Form21: TForm21
  Left = 0
  Top = 0
  Caption = 'Form21'
  ClientHeight = 441
  ClientWidth = 644
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCloseQuery = FormCloseQuery
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 644
    Height = 384
    Align = alClient
    Caption = 'Panel1'
    TabOrder = 0
    object VideoWindow1: TVideoWindow
      Left = 1
      Top = 1
      Width = 642
      Height = 382
      Mode = vmVMR
      FilterGraph = FilterGraph1
      VMROptions.Mode = vmrWindowed
      Color = clWhite
      Align = alClient
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 384
    Width = 644
    Height = 57
    Align = alBottom
    Caption = 'Panel2'
    TabOrder = 1
    object Button1: TButton
      Left = 24
      Top = 16
      Width = 75
      Height = 25
      Caption = 'Play'
      TabOrder = 0
      OnClick = Button1Click
    end
    object Button2: TButton
      Left = 128
      Top = 16
      Width = 75
      Height = 25
      Caption = 'Stop'
      TabOrder = 1
      OnClick = Button2Click
    end
  end
  object FilterGraph1: TFilterGraph
    GraphEdit = True
    LinearVolume = True
    Left = 424
    Top = 144
  end
  object OpenDialog1: TOpenDialog
    Left = 344
    Top = 128
  end
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-06 19:22:37

没有对无缝循环的内置支持。是的,你当然可以收到完成事件,寻找回放到开始,并再次运行图形,但这将不可避免地有重新启动延迟和可能的闪烁。

要实现无缝循环,您可以使用multigraph解决方案,在演示图处于短暂停顿且不闪烁的情况下重新启动上游图。或者将自定义过滤器添加到流水线中,以在内部重新启动流,并将其呈现为连续流。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14176784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档