Autor Beitrag
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: So 16.11.03 20:48 
ich will einen screensaver programmieren und möchte auf meiner form einen flash-film laufen lassen. er soll in die exe eingebunden werden. wie mache ich so etwas?

_________________
MFG Rool
Michael Stenzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 133


D3 Prof, D7 PE
BeitragVerfasst: Mo 17.11.03 00:59 
Hallo Rool!

Ich habe hier im Forum schon eine Unit dazu gefunden.
Von sunshine.
Du mußt zuerst ein ActiveX von Macromedia Flashplayer erstellen(ActiveX Importieren)
Die automatische erstellte Unit heißt ShockwaveFlashObjects_TLB.
Weiteres siehe Quelltext von sunshine.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
unit flashmp3; // by sunshine

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, ExtCtrls,
  MPlayer,                     // Important to play Mp3s
  ShockwaveFlashObjects_TLB ; //necessary for Flash
                            

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Label1Click(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure Label3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  Form1 : TForm;
  AppDir : string;
  FRes : TResourceStream;
  FFile : TFileStream;
  mp : TMediaplayer;
  FlashMovie : TShockWaveFlash;
implementation

{$R *.DFM}
{$R *.res}

procedure TForm1.FormCreate(Sender: TObject);
begin
      GetDir(0,AppDir);
      // Create MP3 File
      FRes := TResourceStream.create(hInstance,'Knockmp3',RT_RCDATA);
      Ffile := TFileStream.Create('Knock.mp3',fmCreate);
      Ffile.CopyFrom(Fres,Fres.Size);
      Fres.Free;
      Ffile.Free;

      //Create Flash Movie File
      FRes := TResourceStream.create(hInstance,'Knockswf',RT_RCDATA);
      Ffile := TFileStream.Create('KnockFlash.swf',fmCreate);
      Ffile.CopyFrom(Fres,Fres.Size);
      Fres.Free;
      Ffile.Free;

      //Initialize MP3 Player
      mp := TMediaPlayer.Create(self);
      mp.parent := self;
      mp.visible := false;
      mp.filename := 'Knock.mp3';
      mp.open;

      //Initialize Flashmovie
      FlashMovie := TShockWaveFlash.Create(self);
      FlashMovie.Parent := self;
      FlashMovie.Top := 10;  FlashMovie.Left := 10;
      FlashMovie.height := 200; FlashMovie.Width := 200;
      FlashMovie.BackgroundColor := RGB(0,0,0);
      FlashMovie.Loop := false;

      
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  mp.free;
  DeleteFile(appdir+'\Knock.mp3');
  Deletefile(appdir+'\KnockFlash.swf');


end;

procedure TForm1.Label1Click(Sender: TObject);
begin
  Flashmovie.Movie := appdir+ '\KnockFlash.swf';
  mp.play;
  flashmovie.play;
end;

procedure TForm1.Label2Click(Sender: TObject);
begin
  ShowMessage('Sunshines Flash && Mp3 Example' + #13#13+
              'www.sunshine.2kx.de' +#13+
              'www.freenet.de/sun-shine'+ #13#13+
              'Questions? Mail me! LLoret01@gmx.de'); 
                     
end;

procedure TForm1.Label3Click(Sender: TObject);
begin
  form1.close;
end;

end.



Michael.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mo 17.11.03 07:04 
Zitat:
er soll in die exe eingebunden werden. wie mache ich so etwas?


Erstelle eine Ressource-Datei. Binde diese in Delphi ein und lade
die Flash Datei zur Laufzeit mit TResourceStream.

Genaue Anleitung ist hier zu finden:

www.swissdelphicente.../showcode.php?id=599