Thema: Delphi Mediaplayer Vollbild

Einzelnen Beitrag anzeigen

Benutzerbild von Flogo
Flogo

Registriert seit: 24. Mär 2003
Ort: Freiburg im Breisgau
317 Beiträge
 
Delphi 7 Professional
 
#2
  Alt 27. Mär 2003, 13:07
Ich hab sowas auch mal versucht und bin auf das gleiche Problem gestoßen. Ich habs damals sehr umständlich (mit viel rumrechnerei) gelöst:
Code:
function Rect(Panel: TPanel): TRect;
var Width, Height: Integer; newWidth, newHeight: Single; T: Integer;
begin
  Result := Panel.ClientRect;
  if not GetSizeInfo(Form1.OpDi.FileName, Width, Height) then exit;
  newWidth := (Width * (Result.Bottom - Result.Top)) / Height;
  newHeight := (Height * (Result.Right - Result.Left)) / Width;
  if (newWidth < (Result.Right - Result.Left)) and
     (newHeight > (Result.Bottom - Result.Top)) then
  begin
    T := Round((Result.Right - Result.Left - newWidth) / 2);
    Inc(Result.Left, T);
    Dec(Result.Right, 2*T);
  end
  else if (newHeight < (Result.Bottom - Result.Top)) and
          (newWidth > (Result.Right - Result.Left)) then
  begin
    T := Round((Result.Bottom - Result.Top - newHeight) / 2);
    Inc(Result.Top, T);
    Dec(Result.Bottom, 2*T);
  end;
end;
Du gibst der Function ein Panel das als Display funktioniert (bei fullscreen ist das natürlich maximiert). Die Funktion schaut dann ob das video zu hoch oder zu breit ist und passt das ergebnis dann als displayrect entsprechent an. Dazu brauch man natürlich die Originalgrößen de videos, die folgende Funktion ausliest (nur für AVI mein Prog konnte kein mpg)

Code:
function GetSizeInfo(Name: string; var Width, Height: Integer): Boolean;
var dwParam2: TMCI_OVLY_RECT_PARMS;
    Retval: longint;
begin
  Result := false;
  dwParam2.dwCallback := Form1.MePl.Handle;
  dwParam2.rc.Left  := 0;
  dwParam2.rc.Top   := 0;
  dwParam2.rc.Right := 0;
  dwParam2.rc.Bottom := 0;
  Retval := mciSendCommand(Form1.MePl.DeviceID,MCI_WHERE, MCI_OVLY_WHERE_SOURCE, integer(@dwParam2));
  if Retval <> 0 then exit;
  Width := dwParam2.rc.Right - dwParam2.rc.Left;
  Height := dwParam2.rc.Bottom - dwParam2.rc.Top;
  Result := true;
end;
Wenn jemand ne einfachere Lösung parat hat nur her damit
If one coincidence can occur, then another coincidence can occur. And if one coincidence happens to occur just after another coincidence, then that is just a coincidence.
DNA

www.Anyxist.de
  Mit Zitat antworten Zitat