Hello, de retour pour quelques jours...

J'ai cherché à contrôler la lecture d'une video...

ci-joint :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
107
108
109
110
111
112
113
114
115
 
Unit UVideoButton;
interface
 
uses Flash8;
 
type
  TButton=class(movieClip)
   Private
    w,h,fonction:number;
    procedure skin;
    procedure skin1playpause;
    procedure skin2stop;
    procedure skin3back;
    procedure skin4up;
   Public
    skin1,Skin2:movieclip;
    procedure onPress;override;
    procedure onClick;virtual;
    Constructor Create(parent:movieclip;nbskin,left,top,width,height:number);
  end;
 
implementation
 
Constructor TButton.Create(parent:movieclip;nbskin,left,top,width,height:number);
begin
  inherited Create(parent,'button', movieclip(parent).getNextHighestDepth());
  w:=width;
  h:=height;
  fonction:=nbskin;
  linestyle(3,$e0e0e0);
  BeginFill($c0c0c0);
  moveto(0,h);
  lineto(0,0);
  lineto(w,0);
  linestyle(3,$808080);
  lineto(w,h);
  lineto(0,h);
  skin;
  _x:=left;
  _y:=top;
end;
 
Procedure TButton. skin1playpause;
begin
  skin1:=movieclip.Create(self,'skin1',1);
  skin2:=movieclip.Create(self,'skin2',2);
  With skin1 do
  begin
   BeginFill(clBlack);
   linestyle(2,clBlack);
   moveto(w/4,h/4);
   lineto(3*w/4,h/2);
   lineto(w/4,3*h/4);
  end;
  With skin2 do
  begin
   linestyle(6,clBlack);
   moveto(7*w/20,h/4);
   lineto(7*w/20,3*h/4);
   moveto(13*w/20,h/4);
   lineto(13*w/20,3*h/4);
   _visible:=false;
  end;
end;
 
Procedure TButton. skin2stop;
begin
  BeginFill(clBlack);
  linestyle(2,clBlack);
  moveto(w/4,h/4);
  lineto(3*w/4,h/4);
  lineto(3*w/4,3*h/4);
  lineto(w/4,3*h/4);
  lineto(w/4,h/4);
end;
 
procedure TButton.skin3back;
begin
  linestyle(4,clBlack);
  moveto(3*w/4,h/4);
  Lineto(w/4,h/2);
  moveto(w/4,h/2);
  Lineto(3*w/4,3*h/4);
end;
 
procedure TButton.skin4up;
begin
 linestyle(4,clBlack);
 moveto(w/4,h/4);
 Lineto(3*w/4,h/2);
 moveto(3*w/4,h/2);
 Lineto(w/4,3*h/4);
end;
 
procedure TButton.skin;
begin
 case fonction of
  1:skin1playpause;
  2:skin2stop;
  3:skin3back;
  4:skin4up;
 end;
end;
 
procedure TButton.onClick;
begin
end;
 
procedure TButton.onPress;
begin
 onClick;
end;
 
end.

Le programme :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
program PVideo;
 
uses
  Flash8,UVideoButton;
 
{$FRAME_WIDTH 640}
{$FRAME_HEIGHT 380}
{$BACKGROUND $9999ff}
{$FRAME_RATE 32}
 
// Flash 8 ne permet pas d'instancier l'objet Video par programme
// la directive de compilation $VIDEO permet contourner ce problème
// l'objet est créé statiquement avant le lancement du programme
// il ne reste plus qu'à déclarer une variable "external" pour l'utiliser.
{$VIDEO name="my_video" depth="1" left="0" top="0" width="320" height="240"}
 
(* syntaxe plus compacte équivalement
  {$VIDEO my_video 1 0 20 180 180}
*)
 
type
 
  MyNetStream = class(NetStream)
    procedure onStatus(infoObject: TInfoObject); override;
  end;
 
  MyScreen=class
   btplay,btstop,btback,btNext:TButton;
   constructor Create;
   procedure onPlay(sender:TObject);
   procedure onStop(sender:TObject);
   procedure onBackframe(sender:TObject);
   procedure onNextFrame(sender:TObject);
  end;
 
 
var
  nc: NetConnection;
  ns: MyNetStream;
  vo: Video external 'my_video';
 
Constructor MyScreen.Create;
begin
 btplay:=TButton.Create(_Root,1,10,10,50,50);
 btstop:=TButton.Create(_Root,2,10,70,50,50);
 btback:=TButton.Create(_Root,3,10,130,50,50);
 btNext:=TButton.Create(_Root,4,10,190,50,50);
 
 nc := NetConnection.Create;
 nc.connect(nil);
 ns := MyNetStream.Create(nc);
 vo.attachVideo(ns);
 vo._height:=stage.height;
 
 with vo do
 begin
  _width:=320*_height/240;
  _x:=(stage.width-_width)/2;
  smoothing:=true;
 end;
 
 ns.play('Execute.re.flv');
 ns.pause;
 
 btplay.onClick:=onPlay;
 btStop.onClick:=onStop;
 btBack.onClick:=onBackframe;
 btNext.onClick:=onNextframe;
end;
 
procedure MyScreen.onPlay(sender:TObject);
begin
 with btplay.skin1 do _visible:=not _visible;
 with btplay.skin2 do _visible:=not _visible;
 ns.pause;
end;
 
procedure MyScreen.onStop(sender:TObject);
begin
 btplay.skin1._visible:=true;
 btplay.skin2._visible:=false;
 ns.play('Execute.re.flv');
 ns.pause;
end;
 
procedure MyScreen.onBackframe(sender:TObject);
begin
  with ns do seek(time-1/currentFps);  //ici à la frame précédente
end;
 
procedure MyScreen.onNextFrame(sender:TObject);
begin
  with ns do seek(time+1/currentFps);// Je devrais passer à chaque fois à la frame suivante !   Time+1/10
end;
 
procedure MyNetStream.onStatus(infoObject: TInfoObject);
begin
  if infoObject.code = 'NetStream.Buffer.Empty' then ns.play('Excute.re.flv') ;
end;
 
 
begin
 MyScreen.Create;
end.
En fait, j'aimerais pouvoir contrôler l'image par image avec les deux derniers boutons et je ne vois pas comment faire...

merci

anthony