Einzelnen Beitrag anzeigen

SvenLittkowski

Registriert seit: 18. Dez 2004
98 Beiträge
 
#3

Re: Mediaplayer-Probleme (Absturz bei Öffnen eines neuen Cli

  Alt 18. Dez 2004, 12:01
Hier ist der vollständige Code.

Erläuterung:
es gibt drei Fenster.
Box1 - Hintergrund der Anwendung mit TProgressBar
Box2 - Enthält alle Buttons und andere Komponenten, kann verschoben werden
Box3 - Enthält TPanel als Anzeige

Box1 öffnet automatisch Box2 und Box3.
Box2 lädt automatisch ein "Intro"-Video.

WICHTIGE ÄNDERUNG:
Nun gibt es nur noch einen Start- und einen Stop-Button, die Filme werden über TRadioButton ausgewählt.

Delphi-Quellcode:
unit Box2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IAeverButton, jpeg, ExtCtrls, MPlayer;

type
  TFormBeta = class(TForm)
    ButtonPlay: TIAeverButton;
    ButtonStop: TIAeverButton;
    ImagePlayer: TImage;
    Player: TMediaPlayer;
    TimerPrologue: TTimer;
    ButtonEnde: TIAeverButton;
    ButtonAbout: TIAeverButton;
    RadioButtonIntro: TRadioButton;
    RadioButtonInfo: TRadioButton;
    RadioButtonEDV: TRadioButton;
    RadioButtonKommunikation: TRadioButton;
    RadioButtonVertrieb: TRadioButton;
    RadioButtonLeitung: TRadioButton;
    RadioButtonAccounting: TRadioButton;
    RadioButtonHandling: TRadioButton;
    RadioButtonLanguages: TRadioButton;
    Label1: TLabel;
    TimerNotify: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TimerPrologueTimer(Sender: TObject);
    procedure ImagePlayerMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ImagePlayerMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ColorsH(Sender: TObject);
    procedure ColorsN(Sender: TObject);
    procedure ButtonPlayMouseExit(sender: TObject);
    procedure ButtonPlayMouseEnter(sender: TObject);
    procedure Button09MouseEnter(sender: TObject);
    procedure ButtonEndeMouseEnter(sender: TObject);
    procedure ButtonAboutMouseEnter(sender: TObject);
    procedure ButtonStopMouseEnter(sender: TObject);
    procedure ButtonForeMouseEnter(sender: TObject);
    procedure ButtonEndeMouseExit(sender: TObject);
    procedure ButtonAboutMouseExit(sender: TObject);
    procedure ButtonStopMouseExit(sender: TObject);
    procedure ButtonPlayClick(Sender: TObject);
    procedure ButtonEndeClick(Sender: TObject);
    procedure PlayerNotify(Sender: TObject);
    procedure ButtonStopClick(Sender: TObject);
    procedure TimerNotifyTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
 ModeStr: array[TMPModes] of string=('Not ready', 'Stopped', 'Playing', 'Recording', 'Seeking', 'Paused', 'Open');

var
  FormBeta: TFormBeta;
  StartX: Integer;
  StartY: Integer;
  Status: String;

implementation

uses Box1, Box3;

{$R *.dfm}

procedure TFormBeta.FormCreate(Sender: TObject);
begin
 FormBeta.Width:=ImagePlayer.Width;
 FormBeta.Height:=ImagePlayer.Height;
 Player.Notify:=True;
end;

procedure TFormBeta.FormShow(Sender: TObject);
begin
 Player.FileName:='T_Intro.avi';
 Player.Open;
 Player.DisplayRect:=FormDelta.PanelMovie.ClientRect;
 Player.TimeFormat:=tfHMS;
 FormAlpha.Progress.Maximum:=Player.Length;
 FormAlpha.Progress.Position:=0;
 Player.Play;
 ButtonEnde.Font.Name:='System';
 ButtonStop.Font.Name:='System';
 ButtonPlay.Font.Name:='System';
 ButtonAbout.Font.Name:='System';
end;

procedure TFormBeta.TimerPrologueTimer(Sender: TObject);
begin
 FormAlpha.Progress.Position:=Player.Position;
 Player.DisplayRect:=FormDelta.PanelMovie.ClientRect;
 if Player.Position=Player.Length then
 begin
  FormAlpha.Progress.Position:=0;
  FormAlpha.Progress.Visible:=False;
 end;
end;

procedure TFormBeta.ImagePlayerMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 StartX:=X;
 StartY:=Y;
end;

procedure TFormBeta.ImagePlayerMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
 if ssLeft in Shift then
 begin
  if X>StartX then
  begin
   FormBeta.Left:=FormBeta.Left+(X-StartX);
   FormDelta.Left:=FormBeta.Left+182;
  end
  else
  if X<StartX then
  begin
   FormBeta.Left:=FormBeta.Left-(StartX-X);
   FormDelta.Left:=FormBeta.Left+182;
  end;
  if Y>StartY then
  begin
   FormBeta.Top:=FormBeta.Top+(Y-StartY);
   FormDelta.Top:=FormBeta.Top+44;
  end
  else
  if Y<StartY then
  begin
   FormBeta.Top:=FormBeta.Top-(StartY-Y);
   FormDelta.Top:=FormBeta.Top+44;
  end;
 end;
end;

procedure TFormBeta.ColorsH(Sender: TObject);
begin
 with Sender as TIAeverButton do
 begin
  if ButtonColor=$002E4881 then
  begin
   ButtonColor:=$00106EB8;
   ButtonColor1:=$0024365B;
   Font.Color:=$00FFFFFF;
  end
  else
  if ButtonColor=$0092A8C7 then
  begin
   ButtonColor:=$009CD7F3;
   ButtonColor1:=$009CD7F3;
   Font.Color:=$00FFFFFF;
  end;
 end;
end;

procedure TFormBeta.ColorsN(Sender: TObject);
begin
 with Sender as TIAeverButton do
 begin
  if ButtonColor=$00106EB8 then
  begin
   ButtonColor:=$002E4881;
   ButtonColor1:=$0024365B;
   Font.Color:=$0092A8C7;
  end
  else
  if ButtonColor=$009CD7F3 then
  begin
   ButtonColor:=$0092A8C7;
   ButtonColor1:=$0092A8C7;
   Font.Color:=$00000000;
  end;
 end;
end;

procedure TFormBeta.ButtonPlayMouseExit(sender: TObject);
begin
 ColorsN(Sender);
end;

procedure TFormBeta.ButtonPlayMouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.Button09MouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.ButtonEndeMouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.ButtonAboutMouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.ButtonStopMouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.ButtonForeMouseEnter(sender: TObject);
begin
 ColorsH(Sender);
end;

procedure TFormBeta.ButtonEndeMouseExit(sender: TObject);
begin
 ColorsN(Sender);
end;

procedure TFormBeta.ButtonAboutMouseExit(sender: TObject);
begin
 ColorsN(Sender);
end;

procedure TFormBeta.ButtonStopMouseExit(sender: TObject);
begin
 ColorsN(Sender);
end;

procedure TFormBeta.ButtonPlayClick(Sender: TObject);
begin
 if RadioButtonIntro.Checked=True then Player.FileName:='T_Intro.avi'
 else
 if RadioButtonInfo.Checked=True then Player.FileName:='T_Info.avi'
 else
 if RadioButtonEDV.Checked=True then Player.FileName:='T_EDV.avi'
 else
 if RadioButtonHandling.Checked=True then Player.FileName:='T_GroupEventHandling.avi'
 else
 if RadioButtonKommunikation.Checked=True then Player.FileName:='T_Bürokommunikation.avi'
 else
 if RadioButtonLanguages.Checked=True then Player.FileName:='T_Language.avi'
 else
 if RadioButtonVertrieb.Checked=True then Player.FileName:='T_Vertriebssystem.avi'
 else
 if RadioButtonLeitung.Checked=True then Player.FileName:='T_Travel.avi'
 else
 if RadioButtonAccounting.Checked=True then Player.FileName:='T_Accounting.avi';
 Player.Open;
 Player.DisplayRect:=FormDelta.PanelMovie.ClientRect;
 Player.TimeFormat:=tfHMS;
 FormAlpha.Progress.Maximum:=Player.Length;
 FormAlpha.Progress.Position:=0;
 Player.Play;
end;

procedure TFormBeta.ButtonEndeClick(Sender: TObject);
begin
 Application.Terminate;
end;

procedure TFormBeta.PlayerNotify(Sender: TObject);
begin
 with Sender as TMediaPlayer do
 begin
  Notify:=True;
  if ModeStr[Mode]='Playingthen
  begin
   Label1.caption:=ModeStr[Mode];
   TimerPrologue.Enabled:=True;
   FormAlpha.Progress.Position:=0;
   FormAlpha.Progress.Visible:=True;
   ButtonPlay.Enabled:=False;
   ButtonStop.Enabled:=True;
   RadioButtonIntro.Font.Color:=$0024365B;
   RadioButtonInfo.Font.Color:=$0024365B;
   RadioButtonEDV.Font.Color:=$0024365B;
   RadioButtonHandling.Font.Color:=$0024365B;
   RadioButtonKommunikation.Font.Color:=$0024365B;
   RadioButtonLanguages.Font.Color:=$0024365B;
   RadioButtonVertrieb.Font.Color:=$0024365B;
   RadioButtonLeitung.Font.Color:=$0024365B;
   RadioButtonAccounting.Font.Color:=$0024365B;
   Notify:=True;
  end
  else
  if ModeStr[Mode]<>'Playingthen
  begin
   Label1.caption:=ModeStr[Mode];
   TimerPrologue.Enabled:=False;
   FormAlpha.Progress.Position:=0;
   FormAlpha.Progress.Visible:=False;
   ButtonPlay.Enabled:=True;
   ButtonStop.Enabled:=False;
   RadioButtonIntro.Font.Color:=$002E4881;
   RadioButtonInfo.Font.Color:=$002E4881;
   RadioButtonEDV.Font.Color:=$002E4881;
   RadioButtonHandling.Font.Color:=$002E4881;
   RadioButtonKommunikation.Font.Color:=$002E4881;
   RadioButtonLanguages.Font.Color:=$002E4881;
   RadioButtonVertrieb.Font.Color:=$002E4881;
   RadioButtonLeitung.Font.Color:=$002E4881;
   RadioButtonAccounting.Font.Color:=$002E4881;
   Notify:=True;
  end;
  Notify:=True;
 end;
end;

procedure TFormBeta.ButtonStopClick(Sender: TObject);
begin
 Player.Close;
 Player.FileName:='';
end;

procedure TFormBeta.TimerNotifyTimer(Sender: TObject);
begin
 Player.Notify:=True;
 Label1.caption:=ModeStr[Player.Mode];
end;

end.
Wie man sieht, habe ich schon erfolglos versucht, mehrere Wege zu gehen (z.B. Notify).

Vielen aufrechten Dank für Eure Hilfe.

Sven
  Mit Zitat antworten Zitat