Changeset 201
- Timestamp:
- May 8, 2020, 11:14:09 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/Sound.pas
r189 r201 12 12 TPlayStyle = (psAsync, psSync); 13 13 14 { TSoundPlayer } 15 14 16 TSoundPlayer = class(TForm) 15 17 private 16 18 {$IFDEF WINDOWS} 19 PrevWndProc: WNDPROC; 17 20 procedure OnMCI(var m: TMessage); message MM_MCINOTIFY; 21 public 22 constructor Create(AOwner: TComponent); override; 18 23 {$ENDIF} 19 24 end; … … 23 28 TSound = class 24 29 private 30 {$IFDEF LINUX} 25 31 PlayCommand: string; 26 {$IFDEF LINUX}27 32 SoundPlayerAsyncProcess: TAsyncProcess; 28 33 SoundPlayerSyncProcess: TProcess; … … 82 87 OpenParm.lpstrElementName := PChar(FFileName); 83 88 mciSendCommand(0, MCI_Open, MCI_WAIT or MCI_OPEN_ELEMENT or 84 MCI_OPEN_SHAREABLE, integer(@OpenParm));89 MCI_OPEN_SHAREABLE, DWORD_PTR(@OpenParm)); 85 90 FDeviceID := OpenParm.wDeviceID; 86 91 end … … 239 244 240 245 {$IFDEF WINDOWS} 246 function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LRESULT; stdcall; 247 var 248 Message: TMessage; 249 begin 250 if (uMsg = MM_MCINOTIFY) then begin 251 Message.msg := uMsg; 252 Message.wParam := wParam; 253 Message.lParam := lParam; 254 SoundPlayer.OnMCI(Message); 255 end; 256 Result := CallWindowProc(SoundPlayer.PrevWndProc, Ahwnd, uMsg, WParam, LParam); 257 end; 258 241 259 procedure TSoundPlayer.OnMCI(var m: TMessage); 242 260 begin 243 if (m.wParam = MCI_N otify_Successful) and (PlayingSound <> nil) then261 if (m.wParam = MCI_NOTIFY_SUCCESSFUL) and (PlayingSound <> nil) then 244 262 begin 245 263 PlayingSound.Reset; 246 264 PlayingSound := nil; 247 265 end; 266 end; 267 268 constructor TSoundPlayer.Create(AOwner: TComponent); 269 begin 270 inherited; 271 // MM_MCINOTIFY is not handled by LCL, fallback to low lever handling 272 // https://wiki.lazarus.freepascal.org/Win32/64_Interface#Processing_non-user_messages_in_your_window 273 PrevWndProc := Windows.WNDPROC(SetWindowLongPtr(Self.Handle, GWL_WNDPROC, PtrInt(@WndCallback))); 248 274 end; 249 275 {$ENDIF} … … 274 300 275 301 function Play(Item: string; Index: Integer = -1): Boolean; 276 {$IFNDEF DEBUG}277 302 var 278 303 WavFileName: string; 279 {$ENDIF}280 304 begin 281 305 Result := False; 282 {$IFNDEF DEBUG}283 306 if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then 284 307 begin … … 292 315 // SndPlaySound(pchar(GetSoundsDir + DirectorySeparator + WavFileName + '.wav'), SND_ASYNC) 293 316 PlaySound(GetSoundsDir + DirectorySeparator + WavFileName); 294 {$ENDIF}295 317 end; 296 318 297 319 procedure PreparePlay(Item: string; Index: Integer = -1); 298 {$IFNDEF DEBUG}299 320 var 300 321 WavFileName: string; 301 {$ENDIF} 302 begin 303 {$IFNDEF DEBUG} 322 begin 304 323 if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then 305 324 Exit; … … 308 327 if (WavFileName <> '') and (WavFileName[1] <> '[') and (WavFileName <> '*') then 309 328 PrepareSound(GetSoundsDir + DirectorySeparator + WavFileName); 310 {$ENDIF}311 329 end; 312 330
Note:
See TracChangeset
for help on using the changeset viewer.