Autor Beitrag
Daniel_100
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mo 28.07.03 17:03 
Hallo!

Ich habe zu einem Mediaplayer eine Trackbar hinzugefügt, damit (gafisch) angezeigt wird, wieviel von einem Lied schon abgespielt wurde. Wenn man nun mit der Maus den Regler an der Trackbar verschiebt, soll das Lied dort weiter spielen, wo er dann abgelegt wurde. Ich hab es schon mit folgendem Code für TrackBar1Change probiert, aber dass klappt ja nicht, weil die Zeit immer weiter läuft und somit der Regler bewegt wird:
ausblenden Delphi-Quelltext
1:
Trackbar1.position := mediaplayer1.position;					


Wie geht es denn dann?

Danke

Daniel
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Mo 28.07.03 18:38 
hi

versuchs doch mla umgekehrt ;-)

ausblenden Delphi-Quelltext
1:
 MediaPlayer1.Position := TrackBar1.Position;					


müsste so eigentlich gehen...

fcg

_________________
.: Wer für alles offen ist, kann nicht ganz dicht sein! :.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mo 28.07.03 19:35 
Zitat:
müsste so eigentlich gehen...


Es müsste so gehen, tuts aber nicht.


Ich nehm jetzt mal so ein Beispiel:
Eine Dateiname ist vorhanden...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Button1Click(Sender: TObject);
begin
mediaplayer1.Open;
mediaplayer1.Play;
trackbar1.Max := mediaplayer1.Length;
timer1.enabled := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
trackbar1.Position := mediaplayer1.Position;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
MediaPlayer1.Position := TrackBar1.Position;
mediaplayer1.play;
end;


Wenn ich auf den Button1 klicke, fängt das Lied zwar an zu spielen, macht aber nach jedem Intervall des Timers eine Pause. Und setzt dann mit
mediaplayer1.play; der Trackbar1 fort.

Da ist doch was faul?!? :autsch:
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Mo 28.07.03 20:16 
so schau mal hier. Der Code funzt bei mir 8ist getestet!!)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.onChange(Sender: TObject);
begin
 MediaPlayer1.Position := TrackBar1.Position;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 Trackbar1.position := mediaplayer1.position;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 MediaPLayer1.Play;
 TrackBar1.max := MediaPLayer1.Length;
end;


Der Klick aufn Button bewirkt halt das Absspielen, und das Timerintervall ist 1000 Millisekunden!

fcg

_________________
.: Wer für alles offen ist, kann nicht ganz dicht sein! :.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mo 28.07.03 21:00 
Zitat:
ausblenden Delphi-Quelltext
1:
procedure TForm1.onChange(Sender: TObject);					


Der Compiler zeigt bei mir aber an, dass "onChange" und der darauffolgende MediaPLayer1 und TrackBar1 ein "Undeclared identifier" ist.
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 28.07.03 21:26 
Das wird daran liegen, dass TForm das Ereignis OnChange nicht kennt.

Eigentlich müsste das
ausblenden Delphi-Quelltext
1:
procedure TForm1.TrackBar1Change(Sender: TObject);					

heißen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Di 29.07.03 11:24 
Bei mir funzt es immer noch nicht; Kannst du (oder jamand anders) mal den gesamten Code, samt uses, type u.s.w., posten.
Das wäre nett.

Hier ist mein "falscher":

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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    MediaPlayer1: TMediaPlayer;
    Button1: TButton;
    TrackBar1: TTrackBar;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Trackbar1.position := mediaplayer1.position;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
mediaplayer1.open;
 MediaPLayer1.Play;
 TrackBar1.max := MediaPLayer1.Length;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
MediaPlayer1.Position := TrackBar1.Position;
end;

end.


Danke
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Di 29.07.03 12:28 
Hier ist mal der gesamte Code:
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MediaPlayer1: TMediaPlayer;
    TrackBar1: TTrackBar;
    Timer1: TTimer;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  MediaPlayer1.Open;
  MediaPlayer1.Play;
  TrackBar1.Max := MediaPlayer1.Length;
  Timer1.Enabled := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  TrackBar1.Position := MediaPlayer1.Position;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
  MediaPlayer1.Position := TrackBar1.Position;
  MediaPLayer1.Play;
end;

end.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Di 29.07.03 13:31 
Bei dir funzt der Code wirklich :eyecrazy: ?!?!

Bei mir auf alle Falle immer noch nicht (nach jedem Intervall kurze Pause), obwohl ich den Code jetzt ganauso eingefügt hab, wie du es gepostet hast. :?!?:
Kannst du mir dann vielleicht dein Programm mailen, mit Projekt, wenns geht? :roll:

Danke
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: Di 29.07.03 13:51 
@Daniel: Setz doch mal den Intervall des Timers auf "1". Vielleicht klappt's dann ja besser.

_________________
Hasta La Victoria Siempre
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Di 29.07.03 18:05 
Das hab ich schon probiert, dann kommen die Pausen ganz schnell hinternander und man hört garnichts mehr!
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Mi 30.07.03 12:43 
mit welcher Delphi Version arbeitest du denn??

_________________
.: Wer für alles offen ist, kann nicht ganz dicht sein! :.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mi 30.07.03 13:35 
Mit D7. Ich habs aber auch schon in D6 ausprobiert -> nichts anders.


Zuletzt bearbeitet von Daniel_100 am Mi 30.07.03 14:19, insgesamt 1-mal bearbeitet
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mi 30.07.03 13:57 
Ebengrad hab ich es unter D3 getestet und da funzt es :shock: ! Was ist denn da anders? :!:
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: Mi 30.07.03 20:58 
@Daniel: Versuch mal folgendes:

In der OnMouseDown-Prozedur des Trackbars, baust du ein, daß der MediaPlayer stoppen soll

ausblenden Delphi-Quelltext
1:
MediaPlayer1.Pause;					


und ins OnMouseUp-Ereignis des Trackbars baust du folgendes ein:

ausblenden Delphi-Quelltext
1:
2:
MediaPlayer1.Position:=Trackbar1.Position;
MediaPlayer1.Play;


Sag mir mal bitte, ob das funktioniert. Ich habe das mal eben so ausm Kopf überlegt. :-)

_________________
Hasta La Victoria Siempre
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Do 31.07.03 09:59 
Hallo und guten Morgen.
Das mit OnMousedown bzw. Onmouseup-Prozedur kann nicht funktionieren, da es doch überhaupt keine gibt.
Logiqu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP
Delphi 2006 Pro
BeitragVerfasst: Do 31.07.03 10:21 
@daniel_100: gib mal deine e-mail-adresse, dann schicke ich dir mal ne trackbar mit mousedown- und mouse-up-funktion. die habe ich vor ein paar tagen mal schnell geschrieben, weil das problem schonmal hier im forum aufgetreten ist...

_________________
Logiqu. Just feel it...
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Do 31.07.03 10:56 
@Daniel: ich hatte es auch mit Del3 gemacht... Aber kein plan warum das mit Del 6 bzw Del7 wieder mla nit geht...

fcg

_________________
.: Wer für alles offen ist, kann nicht ganz dicht sein! :.
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Fr 01.08.03 15:42 
@Logiqu: Ich hab jetzt "Zeige meine E-Mail-Adresse immer an" eingeschaltet. Kannst mir jetzt den Code schicken...
Logiqu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP
Delphi 2006 Pro
BeitragVerfasst: Mo 04.08.03 09:22 
sorry, war das wochenende nicht zu hause, habe dir die komponente aber eben zugeschickt (von coolsven...)

_________________
Logiqu. Just feel it...