Autor Beitrag
dac424
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Do 10.08.06 20:00 
hallo liebe Leute ich mal wieder wenn ich mein Programm starte wird andauernt das wave gespielt ohne das der Teimer überhaubt sagt das er es spielen soll

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function PlayMySound(x: Pointer) : Longint; stdcall;
begin
  Result:=0;
  if WaveOutGetNumDevs > 0 then begin
    sndPlaySound('bake1.wav',SND_SYNC);
  end
  else
  
end;


Hier soll der Teimer aktiviert werden und gestoppt werden, sprich auch das Play abgebrochen werden was er auch nicht tut.

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:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
begin
  if Vers(tc,false) = getmacaddress then p:=7
  else p:=9;
 // edit2.Text:='c';
  Records := 1024;
   try
  err := tsrGetSpeakers( @IDs, @records);
  except
  tsrGetLastError(@ErrorMessage, SizeOf(ErrorMessage));
  showmessage(ErrorMessage);
  //memo1.Text:=memo1.Text+'error by tsrget-'+inttostr(err);
  check.Enabled:=false;
  end;
  try
  err_get:=tsrGetUserInfo(@gateway);
  except
    tsrGetLastError(@ErrorMessage, SizeOf(ErrorMessage));
  showmessage(ErrorMessage);
  if not err_get =0 then
  showmessage('Fehler bei Init. der TsRemote Lib('+inttostr(err_get)+')');
  end;

   speak:=16;
  if form3.cc.Checked then speak:=17;
  idle:=0;
  if form3.cc.Checked then idle:=1;
  if form3.whisper.Checked then whisper:=1
  else whisper:=0;

  if away=1 then begin
  if form3.cc.Checked then speak:=9
  else speak:=8;
   if form3.cc.Checked then idle:=9
  else idle:=8;
      end;
  if Records > 0 then   //wenn jmd. spricht
  begin
      if IDs[0] <> gateway.Player.PlayerID then    // der der spricht bin nicht ich
      begin


//       Relay.Enabled:=false;

         Label8.Caption:='Barke wurde abgebrochen';
          sndPlaySound(nil,0);
          CanPlay := false;
          bake.Enabled:=false;
           sndPlaySound(nil,0);
           CanPlay := true;
          if p = 7 then begin
           if pin = 'dtr' then DTR(true);
            if pin2 = 'rts' then RTS(true);
            //edit2.text:='hallo';
           end;
           onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'ON_BIT');
//######################################################## Lautstärke auf 0
            if (form3.checkbox1.Checked = true) then begin
            if s_mic.checked then  set_vol :=2;
            if s_line.Checked  then set_vol:=3;
            if MSSMERR_NOERROR=MSSMixer_SetGenericVolume(MSSMixerCtrl,SrcCtrl[set_vol].DestType,SrcCtrl[set_vol].SourceType,0,0) then
             DeferSynchControls;
             edit1.text:='set 0 '+inttostr(mic_vol);
             end;
//########################################################
             if (gateway.Player.PlayerFlags <> idle)  then begin
               gateway.Player.PlayerFlags := idle;
               tsrSetPlayerFlags(gateway.Player.PlayerFlags);

            end;
        end
       else if IDs[0] = gateway.Player.PlayerID then // der der spricht bin ich
        begin
         bake.Enabled:=false;
         Label8.Caption:='Barke wurde abgebrochen';
        x:=1;
        {  if switch.Checked = True then s_mic.Checked:= true;
   if switch.Checked = False then s_line.Checked:= true;  }

           // edit2.Text:='b2-'+inttostr(IDS[0])+'-'+inttostr(gateway.Player.PlayerID);
//if MSSMERR_NOERROR=MSSMixerCtrl.SetGenericVolume(SrcCtrl[mic_line].DestType,SrcCtrl[mic_line].SourceType,s_links,s_rechts) then
////DeferSynchControls;
//###################################################   auf norm bringen
            if s_mic.checked then  set_vol :=2;
            if s_line.Checked  then set_vol:=3;
             if MSSMERR_NOERROR=MSSMixer_SetGenericVolume(MSSMixerctrl,SrcCtrl[set_vol].DestType,SrcCtrl[set_vol].SourceType,mic_vol,mic_vol) then
             DeferSynchControls;
             edit1.text:=inttostr(mic_vol);
//###################################################
     if (gateway.Player.PlayerFlags <> idle)  then begin
               gateway.Player.PlayerFlags := idle;
               tsrSetPlayerFlags(gateway.Player.PlayerFlags);
               end;
       end;//else id=gateway

  end
 else   //wenn keiner oder mehr als einer spricht
  begin


    if x=1 then begin
   if (form3.Bake.Checked = true ) then begin
  Label8.Caption:='Barke aktiv';
  Bake.Enabled:=true;
  if (form3.Beep.Checked = true) then begin
  x:=100;
           if p = 7 then begin
           if pin = 'dtr' then DTR(true);
            if pin2 = 'rts' then RTS(true);
            end;
  onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'ON_BIT');
 //  if IDs[0] <> gateway.Player.PlayerID then begin


 sleep (100);
 sndPlaySound(PChar('beep.wav'),SND_ASYNC);
   CanPlay := False;
   sleep (500);

 // CanPlay := true;
  if p = 7 then begin
  if pin = 'dtr' then DTR(false);
  if pin2 = 'rts' then RTS(false);
  end;

 onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'OFF_BIT');
end;
end;
end;
   if CanPlay then
 begin

  if (form3.Beep.Checked = true) then begin
  //  if IDs[0] <> gateway.Player.PlayerID then begin
 sndPlaySound(PChar('beep.wav'),SND_ASYNC);
  CanPlay := False;
   sleep (500);
 //  x:=100;

   end;
   //end;

 // CanPlay := false;
           if p = 7 then begin
           if pin = 'dtr' then DTR(false);
            if pin2 = 'rts' then RTS(false);
          //  edit2.text:='hallo';
            end;
   if (form3.bake.Checked = true) then begin
  Label8.Caption:='Barke aktiv';
  bake.Enabled:=true;
  end;
  onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'OFF_BIT');


 //  ##############        auf norm bringen
               if s_mic.checked then  set_vol :=2;
            if s_line.Checked  then set_vol:=3;
             if MSSMERR_NOERROR=MSSMixer_SetGenericVolume(Mssmixerctrl,SrcCtrl[set_vol].DestType,SrcCtrl[set_vol].SourceType,mic_vol,mic_vol) then
             DeferSynchControls;
             edit1.text:=inttostr(mic_vol);
 //  ###############
     if (gateway.Player.PlayerFlags <> idle)  then begin
               gateway.Player.PlayerFlags := idle;
               tsrSetPlayerFlags(gateway.Player.PlayerFlags);
              //
               end;


 end;
 end;


end;


das Wave soll gespielt werden wenn die vorgegebe Zeit erreicht ist, aber nur 1 mal
und solange soll DTR und RTS auf True stehen.
Aber wenn ein anderer spricht solte das Wave sofort aufhören zu spielen.

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:
procedure TForm1.BakeTimer(Sender: TObject);
 var
     e: THandle;
    id: DWORD;
begin
  if (form3.Bake.Checked = true) then begin
 Bake.Interval:=(StrToInt(form3.bakenzeit.text))*100 ;
 Label8.Caption:='Barke aktiviert1';
 Bake.Enabled:=false;
  e:=CreateThread(nil,0,TFNThreadStartRoutine(@PlayMySound),@Form1,0,id);
  if e<>0 then CloseHandle(e);
 if Vers(tc,false) = getmacaddress then p:=7
else p:=9;
  if p = 7 then begin
 if pin = 'dtr' then DTR(true); //wird nicht gesetzt
 if pin2 = 'rts' then RTS(true); //das auch nicht warum weis ich auch noch nicht.
 end;

   onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'ON_BIT'); //das macht er auch nicht


 //check.Enabled:=true;
 if Vers(tc,false) = getmacaddress then p:=7
else p:=9;
  if p = 7 then begin
 if pin = 'dtr' then DTR(false);
 if pin2 = 'rts' then RTS(false);

 end;

   onoff.Picture.Bitmap.LoadFromResourceName(HInstance,'OFF_BIT');
// check.Enabled:=true;
   end;
   end;


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
dac424 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 18.08.06 20:46 
Titel: Hat den Keiner eine Ide
Hat den echt keiner eine Idee warum das wave andauernt gespielt wird.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 19.08.06 00:32 
Also,
1. sind Schiebepostings erst nach 23 h erlaubt
2. versteh ich deinen Code mit diesen paar Schnipseln nicht, wäre besser wenn du das ganze Projekt posten könntest

Und 3. erstmal soweit wie ich dich verstanden habe: du möchtest ein Wave abspielen, dabei schaltest du mit dtr/rts schaltest du was um. Was?

Dein Problem scheint ein generelles in der Programmlogik zu sein, aber da steig ich wie gesagt nicht durch.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."