Autor Beitrag
Stefan S.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 184


D5
BeitragVerfasst: Mi 09.03.05 14:29 
Erstens will eine Prozedur machen, die von selber immer wieder durchläuft, sofern ein bestimmter Boolean auf "True" ist und zweitens eine Prozedur, die nach einer bestimmten Zeit aufgerufen wird. Beides hab ich bisher immer mit Timern gemacht (bei 1.: Interval = 1). Aber seit ich weiss, dass Timer von der Rechenleistung des jew. PCs beeinflusst werden, mag ich die nicht mehr. Wie kann ich das dann machen? Bei erstens: Das geht doch sicher ganz einfach, dass eine Prozedur von selbst aufgerufen wird, oder? Und bei zweitens: Was empfehlt ihr mir da? Ist es sinnvoll, dafür die Windows-Uhrzeit zu benutzen, wenn es nicht gerade um Hundertstel geht? Oder macht man das für gewöhnlich anders?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 09.03.05 14:34 
sowas? Ist aber auch furchtbar, denke ich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
repeat
  application.processmessages;
  if BoolscheVar=True then
  begin
    //code der Prozedur
  end;
until false {or andere Var=true, zum Beenden der Endlosschleife};

So läuft die Prozedur immer dann, wenn die Variable wahr ist. Aber ob man das wirklich so programmieren sollte...wohl eher nicht :wink:

_________________
We are, we were and will not be.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 09.03.05 14:38 
Ich mache sowas in UpdateActions der Form. Funktioniert im Prinzip wie eine Idle-Routine. Sie wird immer aufgerufen, wenn das System nichts zu tun hat.
Wenn du eine Variable zum Prüfen des Auslösers hast, ist das ziemlich einfach.
ausblenden Delphi-Quelltext
1:
2:
3:
  protected
    procedure updateActions; Override;
  private

Der Rest dürfte klar sein.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 09.03.05 14:43 
Wie wäre es mit Threads?
Stefan S. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 184


D5
BeitragVerfasst: Mi 09.03.05 15:02 
Was sind Threads bei Delphi? (Ich kenn nur die Threads bei phpBB-Boards... ^^)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 09.03.05 15:05 
Ich glaube, dass Luckie auf seiner Seite ein Tutorial dazu hat:

_________________
We are, we were and will not be.
Stefan S. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 184


D5
BeitragVerfasst: Mi 09.03.05 15:09 
Hm, ich weiss nicht, diese eine Kleinigkeit kann doch nicht so schwierig sein, oder? Wie macht ihr das denn jetzt zum Beispiel, wenn ihr wollt, dass genau 3,5 Sekunden nachdem man auf Button1 geklickt hat Button1.Visible auf False gesetzt wird?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 09.03.05 15:25 
Wenn dazwischen nichts passieren soll: Suche in: Delphi-Forum, Delphi-Library DELAY.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 09.03.05 15:27 
Mit einem Timer.
Dass die Rechenleistung für 3,5 Sekunden geringfügig absinkt, kann doch nicht das große Problem sein, oder?
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mi 09.03.05 15:49 
user profile iconDaSteve hat folgendes geschrieben:
Erstens will eine Prozedur machen, die von selber immer wieder durchläuft, sofern ein bestimmter Boolean auf "True" ist

riecht für mich nach rekursiver funktion/procedure
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure Proc1(kontrolle: boolean; zeit: longint);
var tmpzeit: longint;
begin
  tmpzeit := zeit;
  if kontrolle and (zeit < 60000) then
  begin
    //hier kommt dein code rein 
    Proc1 (kontrolle, tmpzeit+1);
  end else
     exit;    
end;

hab's nicht getestet, aber das sollte Proc1 solange ausführen bis zeit >= 60000 (=1 min), vorausgesetzt kontrolle=TRUE.

hilft das weiter?

Gruß Mike_C

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Stefan S. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 184


D5
BeitragVerfasst: Do 10.03.05 16:08 
user profile iconjasocul hat folgendes geschrieben:
Mit einem Timer.
Dass die Rechenleistung für 3,5 Sekunden geringfügig absinkt, kann doch nicht das große Problem sein, oder?


Hm, es geht darum, dass ein "Wiedergabe Beenden"-Button wieder verschwinden soll, sobald das Video fertig abgespielt ist. Ist halt irgendwie dumm, wenn er zu früh oder zu spät verschwindet...

@Mike_C: Jo, eventuell, werds mal ausprobieren.
thebe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP Home
D6 Enterprise
BeitragVerfasst: Do 10.03.05 18:02 
Das riecht für mich nicht nach Rekursion, besonders weil das den Stack unnötig belasten würde wenn zig tausendmal so nen Ding neuaufgerufen wird. Das riecht für mich eher nach nem Property einer Klasse die inner WriteProcedure (wenn sich der BoolWert auf True ändert) die jeweilige Procedure startet. Das mit der Repeat Schleife und dem ProcessMessages find ich am sinnvollsten, wenns dann auch noch zeitgesteuert sein soll kannst auf den TickCount zugreifen.
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Fr 11.03.05 16:49 
@thebe: ok, du hast recht. aber ohne anwendungsbereicht konnte ich auf sowas nicht schließen
@dasteve: dann frag doch einfach mit dem TMediaPlayer die aktuelle position ab und vergleiche sie mit der Länge von deinem Clip. dann bekommst du auch mit, wann das video zu ende ist und kannst den butten verschwinden lassen.

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Fr 11.03.05 16:59 
wie wär's damit:
TMediaPlayer.OnNotify?

Die Delphi Hilfe hat folgendes geschrieben:
OnNotify occurs upon the completion of a media control method (Back, Close, Eject, Next, Open, Pause, PauseOnly, Play, Previous, Resume, Rewind, StartRecording, Step, or Stop) when the Notify property is set to true before the call to the media control method. After an OnNotify event, the Notify property must be reset to true for the next OnNotify event to occur

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Stefan S. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 184


D5
BeitragVerfasst: Sa 12.03.05 18:24 
Ach, muss ich dann etwa vor MediaPlayer.Play nur MediaPlayer.Notify := True machen und sobald es zu Ende ist ist MediaPlayer.Notify auf "False"? Wenn ja: Sehr nützlich! Dann müsst ich nur noch wissen, wie ich das jetzt am besten mache, dass eine Prozedur die ganze Zeit automatisch abläuft und abfrägt, ob Notify noch True ist. Hab ja einige Vorschläge gehört, aber welcher eignet sich am besten dafür?
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 12.03.05 18:44 
OnNotify ist nicht ein Boolean sondern ein Event. Du kannst im Objekt Inspektor eine Prozedur definieren, die aufgerufen wird, wenn irgendwas mit dem Mediaplayer passiert (analog zu OnClick bei einem Button). Dort fragst du dann ab, ob der Mediaplayer gestoppt ist.
ausblenden Delphi-Quelltext
1:
2:
 if TMediaPlayer(Sender).Mode = mpStopped then
  ShowMessage('Stopped!');
Neidhard von Reuental
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Sa 12.03.05 19:28 
mpStopped wird auch nur aufgerufen wenn beim mediaplayer stop gedrückt wird.
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Sa 12.03.05 19:44 
user profile icondelfiphan hat folgendes geschrieben:
OnNotify ist nicht ein Boolean sondern ein Event.


trotzdem kann ich eine Variable TMediaPlayer.Notify ansprechen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
  Label1.Caption := 'Blink!!! :)';
  (Sender as TMediaPlayer).Notify := True;      //<<--- die Zeile hier ist wichtig!!! sonst bekommst du das  //OnNotify-Event nur ein einziges mal mit!
end;

user profile iconNeidhard von Reuental hat folgendes geschrieben:

mpStopped wird auch nur aufgerufen wenn beim mediaplayer stop gedrückt wird.

klar. wenn du keinen TMediaPlayer sehen willst, nimm deine eigenen Buttons und leite die Aktionen, die bein Klick auf einen x-beliebigen TMediaPlayer-Button ausgeführt werden sollen auf deine eigenen Buttons um.

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 13.03.05 01:36 
Übrigens: In der Hilfe hat es ein gutes Beispiel für den onNotify Event. Man siehe dort nach.
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 13.03.05 15:51 
auf die hatte ich ja auch schon hingewiesen, aber die Essenz von diesem Beispiel (wenn wir das gleiche meinen), steht ja schon in meinem Code-Ausschnitt.

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?