AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Thema durchsuchen
Ansicht
Themen-Optionen

Andorra 2D [Ver. 0.4.5.1, 31.12.08]

Ein Thema von igel457 · begonnen am 24. Nov 2006 · letzter Beitrag vom 14. Sep 2011
 
Sfaizst

Registriert seit: 16. Jun 2008
33 Beiträge
 
#34

AW: Andorra 2D [Ver. 0.4.5.1, 31.12.08]

  Alt 11. Aug 2010, 14:43
Hallö,
musste leider feststellen, das der Loop bei der Videowiedergabe nicht funktioniert, habe mir deshalb was ausgedacht, wie er geht, ist nicht ganz die feine englische, aber es funktioniert: (vielleicht brauchts ja jemand, ich brauchte es, da ich eine kurze videosequenz immer wieder wiederholen wollte)

Die Unit AdVideoTexture (Klasse TAdVideoTexture) sieht nun so aus:
Delphi-Quellcode:
...
  TAdVideoTexture = class(TAdCustomVideoTexture)
    private
      FTimeGap: double;
      FFPS: integer;
      FTmpFPS: integer;
      FTmpTime: double;
      FState: TAdVideoPlayerState;
      FLoop: boolean;
      FSpeed: double;
      FFrameTime: double;

      FOnPlay: TAdNotifyEvent;
      FOnStop: TAdNotifyEvent;
      FOnPause: TAdNotifyEvent;
      FOnClose: TAdNotifyEvent;
      FOnNextFrame: TAdNotifyEvent;

      procedure SetSpeed(AValue:double);
    protected
      procedure DoPlay;virtual;
      procedure DoPause;virtual;
      procedure DoStop;virtual;
      procedure DoNextFrame;virtual;
      procedure DoClose;virtual;

      //NEU DAZUGEKOMMEN:
      property TmpTime : Double read FTmpTime write FTmpTime;
      property TmpFPS : Integer read FTmpFPS write FTmpFPS;
      property FrameTime : Double read FFrameTime write FFrameTime;
      //Abgeändert, damit in die var geschrieben werden kann...
      property TimeGap: double read FTimeGap write FTimeGap;
    public
      {Creates an instance of TAdVideoTexture.}
      constructor Create(AParent: TAd2dApplication);

      {Starts to play the video.}
      procedure Play;virtual;
      {Pauses video playback.}
      procedure Pause;virtual;
      {Stops video playback (resets the data source, clears all buffers)}
      procedure Stop;virtual;
      {Destroys all created video playback objects.}
      procedure Close;virtual;
      {Moves the timer of TAdVideoTexture on, so that playback continues.
      @param(ATimeGap specifies the time that has been passed since the
         last call of ATimeGap in seconds)}

      procedure Move(ATimeGap:double);virtual;

      {Texture that can be accessed when you want to draw the film.}
      property Texture;
      {Time information about the current displayed frame.
       @seealso(TAdVideoPosition)}

      property Time;
      {Information about the current video frame.
       @seealso(TAdVideoInformation)}

      property Info;
      {Current state of the player.}
      property State: TAdVideoPlayerState read FState;
      {The FPS the video is currently played with.}
      property CurrentFPS:integer read FFPS write FFPS; //Abgeändert, damit in die var geschrieben werden kann...
      {Set this property if you want the video to loop.}
      property Loop: boolean read FLoop write FLoop;
      {Use this property to vary playback speed. Default is 1. For example, 0.5
       would mean that the video is played with the half speed.}

      property Speed: double read FSpeed write SetSpeed;

      {Event that is triggered when playback starts.}
      property OnPlay:TAdNotifyEvent read FOnPlay write FOnPlay;
      {Event that is triggered when playback stops.}
      property OnStop:TAdNotifyEvent read FOnStop write FOnStop;
      {Event that is triggered when video playback is pasued.}
      property OnPause:TAdNotifyEvent read FOnPause write FOnPause;
      {Event that is triggered, when a new frame is displayed. This
       event can e.g. be used to synchronize the video to an audio buffer.}

      property OnNextFrame:TAdNotifyEvent read FOnNextFrame write FOnNextFrame;
      {Event that is triggered when the decoder is closed.}
      property OnClose:TAdNotifyEvent read FOnClose write FOnClose;
  end;
...
Neue Unit (Eigene Klasse):
Delphi-Quellcode:
uses ... AdVideo, AdVideoTexture;
...
TNewVideo = class(TAdVideoPlayer)
  private
    //FWidth, FHeight : Integer;
  public
   {procedure SetPropertis(AWidth, AHeight : Integer);
    procedure DoDraw(AdDraw : TAdDraw; TimeGap : Double); Unintressant hier, hab ich aber in meinem Projekt gebraucht }

    procedure Move(ATimeGap:double); override;
    
end;
...
procedure TNewVideo.Move(ATimeGap: Double);
begin
  if GetOpened and (State = vpPlaying) then
  begin
    TmpTime := TmpTime + ATimeGap;
    TimeGap := TimeGap + ATimeGap;
    if (TimeGap > FrameTime) then
      if NextFrame then
      begin
        TmpFPS := TmpFPS + 1;
        TimeGap := TimeGap - FrameTime;
        DoNextFrame;
      end;
    if Pos=Size then
    begin
      if Loop then
         Seek(0) Else
         Stop;
    end;
    if TmpTime > 1 then
    begin
      CurrentFPS := TmpFPS;
      TmpFPS := 0;
      TmpTime := 0;
    end;
  end;
end;
Entschuldigung für den Doppelpost, aber der letzte ist ja schon ne ewigkeit her
Getested mit AdMPEG2Video

P.S.: Meine Pixelkollision funktioniert inzwischen recht gut
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:23 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz