-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathMCI.ahk
1667 lines (1462 loc) · 42.6 KB
/
MCI.ahk
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;- v0.3.1
;*********************
;* *
;* *
;* MCI *
;* *
;* *
;*********************
/*
Each MCI function is documented separately. The following is general
information that relates to the entire library.
Notes
=====
MCI Reference Guide:
http://msdn.microsoft.com/en-us/library/ms709461(VS.85).aspx
Devices referenced within the function documentation:
Driver Type Description
------ ---- -----------
MCIAVI avivideo
MCICDA cdaudio CD audio
dat Digital-audio tape player
digitalvideo Digital video in a window (not GDI-based)
MPEGVideo General-purpose media player
other Undefined MCI device
overlay Overlay device (analog video in a window)
scanner Image scanner
MCISEQ sequencer MIDI sequencer
vcr Video-cassette recorder or player
MCIPIONR videodisc Videodisc (Pioneer LaserDisc)
MCIWAVE waveaudio Audio device that plays digitized waveform
files
Programming Notes
=================
OutputDebug statements in the core of some of the functions that only execute
on condition are permanent and are provided to help the developer find and
eliminate programming errors. Under normal conditions, these debugging
statements should not slow down the operation of the functions because they
"should" only execute when the developer has made a programming/logic error or
if there are unusual conditions.
Credit
======
- Original library released by Fincs as the "Sound_*" library and then as the
"Media_*" library. The orginal libraries are a conversion-to-AutoHotkey
from the AutoIt "Sound.au3" standard library written by RazerM.
This library would not be possible without the significant effort by
Fincs to translate and enhance the original library and RazerM for providing
the original AutoIt library. Some of the code and documentation are from
the libraries provided by Fincs:
Post 1: http://www.autohotkey.com/forum/viewtopic.php?t=20666
Post 2: http://www.autohotkey.com/forum/viewtopic.php?t=22662
- Notify idea and code from Sean:
Post: http://www.autohotkey.com/forum/viewtopic.php?p=132331#132331
- mciGetErrorString DLL function code from PhiLho:
Post: http://www.autohotkey.com/forum/viewtopic.php?p=116011#116011
*/
;----------
;
; Function: MCI_Open
;
;
; Description:
;
; Opens an MCI device and loads the specified file (p_MediaFile).
;
;
; Parameters:
;
; p_MediaFile - A multimedia file. [Required]
;
; p_Alias - Alias [Optional]. A name such as media1. If blank, an
; alias will automatically be generated.
;
; p_Flags - Flags that determine how the device is opened. [Optional]
;
; Some commonly used flags include the following:
;
; type {device_type}
; sharable
;
; If more than one flag is used, separate each flag/flag value with a
; space. For example:
;
; type MPEGVideo sharable
;
; Notes
; -----
; - The "wait" flag is automatically added to the end of the
; command string. This flag directs the device to complete the
; "open" request before returning.
;
;
; - By default, the MCI device that is opened is determined by the
; file's extension. The "type" flag can be used to 1) override
; the default device that is registered for the file extension or
; to 2) open a media file with a file extension that is not
; registered as a MCI file extension.
;
; To see a list of MCI devices that have been registered for your
; computer, go the following registry locations:
;
; Windows NT4/2000/XP/2003/Vista/etc.:
;
; 16-bit:
; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI
;
; 32-bit:
; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI32
;
;
; Windows 95/98/ME:
;
; HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MediaResources\MCI
;
;
; To see a list of registered file extensions and the MCI device
; that has been assigned to each extension, go the following
; locations:
;
; For Windows NT4/2000/XP/2003/Vista, this information is
; stored in the registry at the following location:
;
; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI Extensions
;
;
; For Windows 95/98/ME, this information is stored in the
; %windir%\win.ini file in the "MCI Extensions" section.
;
;
; - Use the "shareable" flag with care. Per msdn, the "shareable"
; flag "initializes the device or file as shareable. Subsequent
; attempts to open the device or file fail unless you specify
; "shareable" in both the original and subsequent open commands.
; MCI returns an invalid device error if the device is already
; open and not shareable. The MCISEQ sequencer and MCIWAVE
; devices do not support shared files."
;
;
; - For a complete list of flags and descriptions for the "open"
; command string, see the "MCI Reference Guide" (link at the top
; of this library).
;
;
; Return value:
;
; Returns the multimedia handle (alias) or a 0 to indicate failure.
; Failure will occur with any of the following conditions:
;
; - The media file does not exist.
;
; - The media file's extension is not a regisitered MCI extension.
; Note: This test is only performed if the "type" flag is not
; specified.
;
; - Non-zero return code from the MCI_SendString function.
;
;
; Remarks:
;
; - Use the MCI_OpenCDAudio function to open a CDAudio device.
;
; - After the device has been successfully opened, this function sets the
; time format to milliseconds. This time format will remain in effect
; until it is manually set to another value or until the device is
; closed.
;
;------------------------------------------------------------------------------
MCI_Open(p_MediaFile,p_Alias="",p_Flags="")
{
Static s_Seq=0
;[==============]
;[ Parameters ]
;[==============]
;-- p_MediaFile
if p_MediaFile<>new
{
;-- Media file exist?
IfNotExist %p_MediaFile%
{
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: The media file can't be
found. Return=0
)
return false
}
;-- "Type" flag not defined?
if InStr(A_Space . p_Flags . A_Space," type ")=0
{
;-- Registered file extension?
SplitPath p_MediaFile,,,l_Extension
;-- Which OS type?
if A_OSType=WIN32_NT ;-- Windows NT4/2000/XP/2003/Vista
RegRead
,l_Dummy
,HKEY_LOCAL_MACHINE
,SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI Extensions
,%l_Extension%
else
{
;-- Windows 95/98/ME
iniRead
,l_Value
,%A_WinDir%\win.ini
,MCI Extensions
,%l_Extension%
if l_Value=ERROR
ErrorLevel=1
}
;-- Not found?
if ErrorLevel
{
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: The file extension for this media
file is not registered as a valid MCI extension. Return=0
)
return false
}
}
;-- Enclose in DQ
p_MediaFile="%p_MediaFile%"
}
;-- Alias
if p_Alias is Space
{
s_Seq++
p_Alias=MCIFile%s_Seq%
}
;[===============]
;[ Open device ]
;[===============]
l_CmdString=open %p_MediaFile% alias %p_Alias% %p_Flags% wait
l_Return:=MCI_SendString(l_CmdString,Dummy)
if l_Return
l_Return:=0
else
l_Return:=p_Alias
;-- Set time format to milliseconds
if l_Return
{
l_CmdString=set %p_Alias% time format milliseconds wait
MCI_SendString(l_CmdString,Dummy)
}
;-- Return to sender
return l_Return
}
;----------
;
; Function: MCI_OpenCDAudio
;
;
; Description:
;
; Opens a CDAudio device.
;
;
; Parameters:
;
; p_Drive - CDROM drive letter. [Optional] If blank, the first CDROM
; drive found is used.
;
; p_Alias - Alias. [optional] A name such as media1. If blank, an
; alias will automatically be generated.
;
; p_CheckForMedia - Check for media [Optional]. The default is TRUE.
;
;
; Return value:
;
; Returns the multimedia handle (alias) or a 0 to indicate failure.
; Failure will occur with any of the following conditions:
; - The computer does not have a CDROM drive.
; - The specified drive is not CDROM drive.
; - Non-zero return code from the MCI_SendString function.
;
; If p_CheckForMedia is TRUE (the default), failure will also occur with
; any of the following conditions:
; - No media was found in the device.
; - Media does not contain audio tracks.
;
;
; Remarks:
;
; After the device has been successfully opened, this function sets
; the time format to milliseconds. This time format will remain in effect
; until it is manually set to another value or until the device is closed.
;
;------------------------------------------------------------------------------
MCI_OpenCDAudio(p_Drive="",p_Alias="",p_CheckForMedia=true)
{
Static s_Seq=0
;-- Parameters
p_Drive=%p_Drive% ;-- Autotrim
p_Drive:=SubStr(p_Drive,1,1)
if p_Drive is not Alpha
p_Drive:=""
;-- Drive not specified
if p_Drive is Space
{
;-- Collect list of CDROM drives
DriveGet l_ListOfCDROMDrives,List,CDROM
if l_ListOfCDROMDrives is Space
{
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: This PC does not have functioning CDROM
drive. Return=0
)
return false
}
;-- Assign the first CDROM drive
p_Drive:=SubStr(l_ListOfCDROMDrives,1,1)
}
;-- Is this a CDROM drive?
DriveGet l_DriveType,Type,%p_Drive%:
if l_DriveType<>CDROM
{
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: The specified drive (%p_Drive%:) is not
a CDROM drive. Return=0
)
return false
}
;-- Alias
if p_Alias is Space
{
s_Seq++
p_Alias=MCICDAudio%s_Seq%
}
;-- Open device
l_CmdString=open %p_Drive%: alias %p_Alias% type cdaudio shareable wait
l_Return:=MCI_SendString(l_CmdString,Dummy)
if l_Return
l_Return:=0
else
l_Return:=p_Alias
;-- Device is open
if l_Return
{
;-- Set time format to milliseconds
l_CmdString=set %p_Alias% time format milliseconds wait
MCI_SendString(l_CmdString,Dummy)
;-- Check for media?
if p_CheckForMedia
{
if not MCI_MediaIsPresent(p_Alias)
{
MCI_Close(p_Alias)
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: Media is not present in the
specified drive (%p_Drive%:). Return=0
)
return false
}
;-- 1st track an audio track?
if not MCI_TrackIsAudio(p_Alias,1)
{
MCI_Close(p_Alias)
outputdebug,
(ltrim join`s
End Func: %A_ThisFunc%: Media in drive %p_Drive%: does not
contain CD Audio tracks. Return=0
)
return false
}
}
}
return l_Return
}
;----------
;
; Function: MCI_Close
;
;
; Description:
;
; Closes the device and any associated resources.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; Closing a device usually stops playback but not always. Consider
; stopping the device before closing it.
;
;
;
;------------------------------------------------------------------------------
MCI_Close(p_lpszDeviceID)
{
Static MM_MCINOTIFY:=0x03B9
;-- Close device
l_Return:=MCI_SendString("close " . p_lpszDeviceID . " wait",Dummy)
;-- Turn off monitoring of MM_MCINOTIFY message?
if OnMessage(MM_MCINOTIFY)="MCI_Notify"
{
;-- Don't proceed unless all MCI devices are closed
MCI_SendString("sysinfo all quantity open",l_OpenMCIDevices)
if l_OpenMCIDevices=0
{
;-- Disable monitoring
OnMessage(MM_MCINOTIFY,"")
}
}
return l_Return
}
;----------
;
; Function: MCI_Play
;
;
; Description:
;
; Starts playing a device.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
; p_Flags - Flags that determine how the device is played. [Optional]
; If blank, no flags are used.
;
; Some commonly used flags include the following:
;
; from {position}
; to {position}
; wait
;
; If more than one flag is used, separate each flag/flag value with a
; space. For example:
;
; from 10144 to 95455 wait
;
; Notes
; -----
; - With the exception of very short sound files (<300 ms), the
; "wait" flag is not recommended. The entire application will be
; non-responsive while the media is being played.
;
; - Do not add the "notify" flag unless you plan to have your
; script trap the MM_MCINOTIFY message outside of this function.
; The "notify" flag is automatically added if the p_Callback
; parameter contains a value.
;
; - For a complete list of flags and descriptions for the "play"
; command string, see the "MCI Reference Guide" (link at the top
; of this library).
;
;
; p_Callback - Function name that is called when the MM_MCINOTIFY message
; is sent. [Optional]. If defined, the "notify" flag is automatically
; added.
;
; Important: The syntax of this parameter and the associated function
; is critical. If not defined correctly, the script may crash.
;
; The function must have at least one parameter. For example:
;
; MyNotifyFunction(NotifyFlag)
;
; Additional parameters are allowed but they must be optional (contain
; a default value). For example:
;
; MyNotifyFunction(NotifyFlag,FirstCall=false,Parm3="ABC")
;
; When a notify message is sent, the approriate MM_MCINOTIFY flag is
; sent to the developer-defined function as the first parameter. See
; the MCI_Notify function for a description and a list of MM_MCINOTIFY
; flag values.
;
;
; p_hWndCallback - Handle to a callback window if the p_Callback
; parameter contains a value and/or if the "notify" flag is defined
; [Optional]. If undefined but needed, the handle to default
; Autohotkey window is used.
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;------------------------------------------------------------------------------
MCI_Play(p_lpszDeviceID,p_Flags="",p_Callback="",p_hwndCallback=0)
{
Static MM_MCINOTIFY:=0x03B9
;-- Build command string
l_CmdString:="play " . p_lpszDeviceID
if p_Flags
l_CmdString:=l_CmdString . A_Space . p_Flags
;-- Notify
p_Callback=%p_Callback% ;-- AutoTrim
if StrLen(p_Callback)
{
l_CmdString:=l_CmdString . " notify"
;-- Attach p_Callback to MCI_Notify function
MCI_Notify(p_Callback,"","","")
;-- Monitor for MM_MCINOTIFY message
OnMessage(MM_MCINOTIFY,"MCI_Notify")
;-- Note: If the MM_MCINOTIFY message was monitored elsewhere,
; this statement will override it.
}
;-- Callback handle
if not p_hwndCallback
{
if InStr(A_Space . l_CmdString . A_Space," notify ")
or StrLen(p_Callback)
{
l_DetectHiddenWindows:=A_DetectHiddenWindows
DetectHiddenWindows On
Process Exist
p_hwndCallback:=WinExist("ahk_pid " . ErrorLevel . " ahk_class AutoHotkey")
DetectHiddenWindows %l_DetectHiddenWindows%
}
}
;-- Send it!
l_return:=MCI_SendString(l_CmdString,Dummy,p_hwndCallback)
return l_Return
}
;----------
;
; Function: MCI_Notify (Internal function. Do not call directly). ;-- Experimental
;
;
; Description:
;
; This function has 2 responsibilties:
;
; 1) If called by the MCI_Play function, wParam contains the name of the
; developer-defined function. This value is assigned to the
; s_Callback static variable for future use.
;
; 2) When called as a result of MM_MCINOTIFY message, this function will
; call the developer-defined function (name stored in the s_Callback
; static variable) sending the MM_MCINOTIFY status flag as the first
; parameter.
;
;
; Parameters:
;
; wParam - Function name or a MM_MCINOTIFY flag. MM_MCINOTIFY flag
; values are as follows:
;
; MCI_NOTIFY_SUCCESSFUL=0x1
; The conditions initiating the callback function have been
; met.
;
; MCI_NOTIFY_SUPERSEDED=0x2
; The device received another command with the "notify" flag
; set and the current conditions for initiating the callback
; function have been superseded.
;
; MCI_NOTIFY_ABORTED=0x4
; The device received a command that prevented the current
; conditions for initiating the callback function from being
; met. If a new command interrupts the current command and
; it also requests notification, the device sends this
; message only and not MCI_NOTIFY_SUPERSEDED.
;
; MCI_NOTIFY_FAILURE=0x8
; A device error occurred while the device was executing the
; command.
;
; lParam - lDevID. This is the identifier of the device initiating the
; callback function. This information is only useful if operating
; more than one MCI device at a time.
;
;
; Return value:
;
; Per msdn, returns 0 to indicate a successful call.
;
;
; Remarks:
;
; This function does not complete until the call to the developer-defined
; function has completed. If a MM_MCINOTIFY message is issued while this
; function is running, the message will be treated as unmonitored.
;
;------------------------------------------------------------------------------
MCI_Notify(wParam,lParam,msg,hWnd)
{
;;;;; Critical
;-- This will cause MM_MCINOTIFY messages to be buffered rather than
; discared if this function is still running when another MM_MCINOTIFY
; message is sent.
Static s_Callback
;-- Internal call?
if lParam is Space
{
s_Callback:=wParam
return
}
;-- Call developer function
if s_Callback is not Space
%s_Callback%(wParam)
return 0
}
;----------
;
; Function: MCI_Stop
;
;
; Description:
;
; Stops playback or recording.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; - After close, a "seek to start" is not done because 1) it slows down the
; the stop request and 2) it may be unwanted. If you need to set the
; media position back to the beginning after a stop, call the MCI_Seek
; function and set the p_Position parameter to 0.
;
; - For (some) CD audio devices, the stop command stops playback and resets
; the current track position to zero.
;
;------------------------------------------------------------------------------
MCI_Stop(p_lpszDeviceID)
{
l_Return:=MCI_SendString("stop " . p_lpszDeviceID . " wait",Dummy)
return l_Return
}
;----------
;
; Function: MCI_Pause
;
;
; Description:
;
; Pauses playback or recording.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; msdn: With the MCICDA, MCISEQ, and MCIPIONR drivers, the pause command
; works the same as the stop command.
;
; Observation: For MCISEQ devices, pause works OK for me.
;
;------------------------------------------------------------------------------
MCI_Pause(p_lpszDeviceID)
{
l_Return:=MCI_SendString("pause " . p_lpszDeviceID . " wait",Dummy)
return l_Return
}
;----------
;
; Function: MCI_Resume
;
;
; Description:
;
; Resumes playback or recording after the device has been paused (see the
; MCI_Pause function).
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; msdn: Digital-video, VCR, and waveform-audio devices recognize this
; command. Although CD audio, MIDI sequencer, and videodisc devices
; also recognize this command, the MCICDA, MCISEQ, and MCIPIONR device
; drivers do not support it.
;
;
; Programming notes:
;
; An alternative to this command is the MCI_Play command. Many devices
; will begin to play where they were last paused. If the device does not
; begin playback correctly, try specifying an appropriate "From"
; and "To" value (if needed) in the p_Flags parameter.
;
;------------------------------------------------------------------------------
MCI_Resume(p_lpszDeviceID)
{
l_Return:=MCI_SendString("resume " . p_lpszDeviceID . " wait",Dummy)
return l_Return
}
;----------
;
; Function: MCI_Record
;
;
; Description:
;
; Starts recording.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
; p_Flags - Flags that determine how the device operates for
; recording. [Optional] If blank, no flags are used.
;
; Some commonly used flags include the following:
;
; from {position}
; to {position}
; insert
; overwrite
;
; If more than one flag is used, separate each flag/flag value with a
; space. For example:
;
; overwrite from 18122 to 26427
;
;
; Notes
; -----
; - The "wait" flag is not recommended. The entire application will
; be non-responsive until recording is stopped with a Stop or
; Pause command.
;
; - For a complete list of flags and descriptions for the "record"
; command string, see the "MCI Reference Guide" (link at the top
; of this library).
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; msdn: Recording stops when a Stop or Pause command is issued. For the
; MCIWAVE driver, all data recorded after a file is opened is discarded if
; the file is closed without saving it.
;
;
; Credit:
;
; Original function and examples by heresy.
;
;------------------------------------------------------------------------------
MCI_Record(p_lpszDeviceID,p_Flags="")
{
l_CmdString=record %p_lpszDeviceID% %p_Flags%
l_Return:=MCI_SendString(l_CmdString,Dummy)
return l_Return
}
;----------
;
; Function: MCI_Save
;
;
; Description:
;
; Saves an MCI file.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
; p_FileName - File name to store a MCI file. [Required] If the file
; does not exist, a new file will be created. If the file exists, it
; will be overwritten.
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;
; Remarks:
;
; This command can overwrite existing files. Use with care.
;
;
; Credit:
;
; Original function and examples by heresy.
;
;------------------------------------------------------------------------------
MCI_Save(p_lpszDeviceID,p_FileName)
{
l_CmdString=save %p_lpszDeviceID% "%p_FileName%"
l_Return:=MCI_SendString(l_CmdString,Dummy)
return l_Return
}
;----------
;
; Function: MCI_Seek
;
;
; Description:
;
; Move to a specified position.
;
;
; Parameters:
;
; p_lpszDeviceID - Device name or alias. [Required]
;
; p_Position - Position to stop the seek. [Required] Value must be
; "start", "end", or an integer.
;
;
; Return value:
;
; Returns the return code from the MCI_SendString function which is 0
; if the command completed successfully.
;
;------------------------------------------------------------------------------
/*
Usage and Programming notes:
MCI Bug?: For some reason, seek for cdaudio doesn't work correctly on the
first attempt. Second and susequent attempts work fine.
*/
MCI_Seek(p_lpszDeviceID,p_Position)
{
;-- Get current status
l_Status:=MCI_Status(p_lpszDeviceID)
;-- Adjust p_Position if necessary
if p_Position not in start,end
{
if p_Position is not Number
p_Position=0