-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.pas
3446 lines (3242 loc) · 125 KB
/
Main.pas
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
{ MPUI-hcb, an MPlayer frontend for Windows
Copyright (C) 2006-2013 Huang Chen Bin <[email protected]>
based on work by Martin J. Fiedler <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit Main;
interface
uses
Windows, TntWindows, SysUtils, TntSysutils, Variants, Classes, Graphics, Messages,
Forms, TntForms, Dialogs, TntDialogs, ComCtrls, TntComCtrls, Buttons, TntButtons,
ExtCtrls, TntExtCtrls, Menus, TntMenus, StdCtrls, TntStdCtrls, ShellAPI, AppEvnts,
ImgList, TntClipBrd, ToolWin, jpeg, Controls, MultiMon, TntSystem,
TntFileCtrl, INIFiles, plist;
const
ES_SYSTEM_REQUIRED = $01;
ES_DISPLAY_REQUIRED = $02;
const
VK_MEDIA_NEXT_TRACK = $B0;
VK_MEDIA_PREV_TRACK = $B1;
VK_MEDIA_STOP = $B2;
VK_MEDIA_PLAY_PAUSE = $B3;
VK_VOLUME_MUTE = $AD;
VK_VOLUME_DOWN = $AE;
VK_VOLUME_UP = $AF;
type
TMainForm = class(TTntForm)
MainMenu: TTntMainMenu;
OMFile: TTntMenuItem;
CPanel: TTntPanel;
BPlay: TTntSpeedButton;
BPause: TTntSpeedButton;
UpdateTimer: TTimer;
SeekBarFrame: TTntPanel;
SeekBarSlider: TTntPanel;
MOpenFile: TTntMenuItem;
MClose: TTntMenuItem;
N1: TTntMenuItem;
MQuit: TTntMenuItem;
OMView: TTntMenuItem;
MSize50: TTntMenuItem;
MSize100: TTntMenuItem;
MSize200: TTntMenuItem;
MFullscreen: TTntMenuItem;
OMSeek: TTntMenuItem;
MSeekF10: TTntMenuItem;
MSeekR10: TTntMenuItem;
MSeekF60: TTntMenuItem;
MSeekR60: TTntMenuItem;
MSeekF600: TTntMenuItem;
MSeekR600: TTntMenuItem;
N2: TTntMenuItem;
MPause: TTntMenuItem;
MPlay: TTntMenuItem;
N3: TTntMenuItem;
MOptions: TTntMenuItem;
MOSD: TTntMenuItem;
MSizeAny: TTntMenuItem;
MOpenURL: TTntMenuItem;
MOnTop: TTntMenuItem;
OMHelp: TTntMenuItem;
MAbout: TTntMenuItem;
MKeyHelp: TTntMenuItem;
MShowOutput: TTntMenuItem;
OMExtra: TTntMenuItem;
N4: TTntMenuItem;
MLanguage: TTntMenuItem;
BFullscreen: TTntSpeedButton;
BStreamInfo: TTntSpeedButton;
MAudio: TTntMenuItem;
N5: TTntMenuItem;
MSubtitle: TTntMenuItem;
MDeinterlace: TTntMenuItem;
MOpenDrive: TTntMenuItem;
MNoDeint: TTntMenuItem;
MSimpleDeint: TTntMenuItem;
MAdaptiveDeint: TTntMenuItem;
OpenDialog: TTntOpenDialog;
MAspects: TTntMenuItem;
MAutoAspect: TTntMenuItem;
MForce43: TTntMenuItem;
MForce169: TTntMenuItem;
MForceCinemascope: TTntMenuItem;
OPanel: TTntPanel;
Logo: TTntImage;
IPanel: TTntPanel;
BPrev: TTntSpeedButton;
BNext: TTntSpeedButton;
MPrev: TTntMenuItem;
MNext: TTntMenuItem;
MShowPlaylist: TTntMenuItem;
N6: TTntMenuItem;
BStop: TTntSpeedButton;
BPlaylist: TTntSpeedButton;
PStatus: TTntPanel;
LTime: TTntLabel;
SeekBar: TTntPanel;
VolFrame: TTntPanel;
VolSlider: TTntPanel;
BMute: TTntSpeedButton;
VolImage: TTntImage;
MAudiochannels: TTntMenuItem;
N7: TTntMenuItem;
MMute: TTntMenuItem;
MStreamInfo: TTntMenuItem;
VolBoost: TTntPanel;
BCompact: TTntSpeedButton;
MCompact: TTntMenuItem;
MStop: TTntMenuItem;
LStatus: TTntLabel;
MenuBar: TTntToolBar;
MFile: TTntToolButton;
MView: TTntToolButton;
MSeek: TTntToolButton;
MVideos: TTntToolButton;
MAudios: TTntToolButton;
MSub: TTntToolButton;
MExtra: TTntToolButton;
MHelp: TTntToolButton;
MVideo: TTntMenuItem;
N11: TTntMenuItem;
Hide_menu: TTntMenuItem;
Mctrl: TTntMenuItem;
MExpand: TTntMenuItem;
MNoExpand: TTntMenuItem;
MSrtExpand: TTntMenuItem;
MSubExpand: TTntMenuItem;
N12: TTntMenuItem;
MSpeed: TTntMenuItem;
MN4X: TTntMenuItem;
MN2X: TTntMenuItem;
M1X: TTntMenuItem;
M2X: TTntMenuItem;
M4X: TTntMenuItem;
MStereo: TTntMenuItem;
MLchannels: TTntMenuItem;
MRchannels: TTntMenuItem;
N14: TTntMenuItem;
MForce85: TTntMenuItem;
MForce54: TTntMenuItem;
MForce221: TTntMenuItem;
MLoadSub: TTntMenuItem;
MSubfont: TTntMenuItem;
N16: TTntMenuItem;
MCustomAspect: TTntMenuItem;
MKaspect: TTntMenuItem;
MNoOnTop: TTntMenuItem;
MAOnTop: TTntMenuItem;
MWOnTop: TTntMenuItem;
BOpen: TTntSpeedButton;
MForce11: TTntMenuItem;
MForce122: TTntMenuItem;
MPopup: TTntPopupMenu;
MPPlay: TTntMenuItem;
MPPause: TTntMenuItem;
MPStop: TTntMenuItem;
N10: TTntMenuItem;
MPPrev: TTntMenuItem;
MPNext: TTntMenuItem;
N8: TTntMenuItem;
MPOpenFile: TTntMenuItem;
MPExpand: TTntMenuItem;
MPNoExpand: TTntMenuItem;
MPSrtExpand: TTntMenuItem;
MPSubExpand: TTntMenuItem;
N13: TTntMenuItem;
MPFullscreen: TTntMenuItem;
MPCtrl: TTntMenuItem;
MPCompact: TTntMenuItem;
OSDMenu: TTntMenuItem;
MPNoOSD: TTntMenuItem;
MPDefaultOSD: TTntMenuItem;
MPTimeOSD: TTntMenuItem;
MPFullOSD: TTntMenuItem;
N9: TTntMenuItem;
MPQuit: TTntMenuItem;
MWheelControl: TTntMenuItem;
MVol: TTntMenuItem;
MDVDT: TTntMenuItem;
SkipBar: TTntPanel;
MSkip: TTntMenuItem;
MIntro: TTntMenuItem;
MEnd: TTntMenuItem;
MSIE: TTntMenuItem;
BSkip: TTntSpeedButton;
BackBar: TTntPanel;
MPWheelControl: TTntMenuItem;
MPVol: TTntMenuItem;
MPSize: TTntMenuItem;
MSize: TTntMenuItem;
MNoOSD: TTntMenuItem;
MDefaultOSD: TTntMenuItem;
MTimeOSD: TTntMenuItem;
MFullOSD: TTntMenuItem;
MOpenDir: TTntMenuItem;
MMaxW: TTntMenuItem;
MPMaxW: TTntMenuItem;
MEqualizer: TTntMenuItem;
MVCDT: TTntMenuItem;
MShowSub: TTntMenuItem;
MRmMenu: TTntMenuItem;
MRnMenu: TTntMenuItem;
N17: TTntMenuItem;
N18: TTntMenuItem;
OMAudio: TTntMenuItem;
OMVideo: TTntMenuItem;
OMSub: TTntMenuItem;
MFlip: TTntMenuItem;
MMirror: TTntMenuItem;
MRotate: TTntMenuItem;
MChannels: TTntMenuItem;
M2ch: TTntMenuItem;
M4ch: TTntMenuItem;
M6ch: TTntMenuItem;
MSpdif: TTntMenuItem;
MRotate0: TTntMenuItem;
MRotate9: TTntMenuItem;
MRotateN9: TTntMenuItem;
N19: TTntMenuItem;
MShot: TTntMenuItem;
N20: TTntMenuItem;
MSEqualizer: TTntMenuItem;
MLoadAudio: TTntMenuItem;
N22: TTntMenuItem;
MSoftVol: TTntMenuItem;
N23: TTntMenuItem;
MUloadAudio: TTntMenuItem;
MScale: TTntMenuItem;
MScale0: TTntMenuItem;
MScale1: TTntMenuItem;
MScale2: TTntMenuItem;
MPan: TTntMenuItem;
N24: TTntMenuItem;
MPan0: TTntMenuItem;
MPan1: TTntMenuItem;
MCX: TTntMenuItem;
MPostproc: TTntMenuItem;
MPostOff: TTntMenuItem;
MPostAuto: TTntMenuItem;
MPostquality: TTntMenuItem;
N25: TTntMenuItem;
N26: TTntMenuItem;
N27: TTntMenuItem;
MUseASS: TTntMenuItem;
N15: TTntMenuItem;
MLoopAll: TTntMenuItem;
MOneLoop: TTntMenuItem;
MShuffle: TTntMenuItem;
N28: TTntMenuItem;
MAudioDelay: TTntMenuItem;
MAudiodelay0: TTntMenuItem;
MAudioDelay1: TTntMenuItem;
MAudioDelay2: TTntMenuItem;
N29: TTntMenuItem;
MSubDelay: TTntMenuItem;
N30: TTntMenuItem;
MSubDelay0: TTntMenuItem;
MSubDelay1: TTntMenuItem;
N31: TTntMenuItem;
MSubDelay2: TTntMenuItem;
MSubStep: TTntMenuItem;
MSubStep0: TTntMenuItem;
MSubStep1: TTntMenuItem;
N32: TTntMenuItem;
MForce155: TTntMenuItem;
MLoadlyric: TTntMenuItem;
N33: TTntMenuItem;
N34: TTntMenuItem;
MUUni: TTntMenuItem;
MSubScale: TTntMenuItem;
MSubScale0: TTntMenuItem;
MSubScale1: TTntMenuItem;
N21: TTntMenuItem;
MSubScale2: TTntMenuItem;
MSCS: TTntMenuItem;
N35: TTntMenuItem;
MRFile: TTntMenuItem;
N36: TTntMenuItem;
MFClear: TTntMenuItem;
N37: TTntMenuItem;
Imagery: TImageList;
M8ch: TTntMenuItem;
MOpenDevices: TTntMenuItem;
Mdownloadsubtitle: TTntMenuItem;
N38: TTntMenuItem;
MDownloadLyric: TTntMenuItem;
MCDT: TTntMenuItem;
SCodepage: TTntMenuItem;
SSD: TTntMenuItem;
UTF1: TTntMenuItem;
UT1: TTntMenuItem;
UTF16BE1: TTntMenuItem;
GB180301: TTntMenuItem;
BIG51: TTntMenuItem;
SHIFTJIS1: TTntMenuItem;
ISO2022JP1: TTntMenuItem;
ISO2022CN1: TTntMenuItem;
ISO2022KR1: TTntMenuItem;
ISO885951: TTntMenuItem;
ISO885971: TTntMenuItem;
ISO885981: TTntMenuItem;
EUCJP1: TTntMenuItem;
EUCKR1: TTntMenuItem;
EUCTW1: TTntMenuItem;
KOI8R1: TTntMenuItem;
IBM8551: TTntMenuItem;
IBM8552: TTntMenuItem;
WINDOWS12511: TTntMenuItem;
WINDOWS12521: TTntMenuItem;
WINDOWS12531: TTntMenuItem;
WINDOWS12551: TTntMenuItem;
N39: TTntMenuItem;
N40: TTntMenuItem;
more1: TTntMenuItem;
HZ1: TTntMenuItem;
ISO885921: TTntMenuItem;
WINDOWS12501: TTntMenuItem;
MBRT: TTntMenuItem;
N41: TTntMenuItem;
MTM: TTntMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BPlayClick(Sender: TObject);
procedure BPauseClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure HotKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure UpdateTimerTimer(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure SeekBarSliderMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure SeekBarSliderMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure SeekBarSliderMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure SeekBarFrameMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure SimulateKey(Sender: TObject);
procedure MSizeClick(Sender: TObject);
procedure MShowOutputClick(Sender: TObject);
procedure MOSDClick(Sender: TObject);
procedure MCloseClick(Sender: TObject);
procedure MAudioClick(Sender: TObject);
procedure MSubtitleClick(Sender: TObject);
procedure MDVDCClick(Sender: TObject);
procedure MDVDAClick(Sender: TObject);
procedure MVCDTClick(Sender: TObject);
procedure MRFClick(Sender: TObject);
procedure MAudiochannelsClick(Sender: TObject);
procedure MSpeedClick(Sender: TObject);
procedure MVideoClick(Sender: TObject);
procedure UpdateMenus(Sender: TObject);
procedure MDeinterlaceClick(Sender: TObject);
procedure MOpenURLClick(Sender: TObject);
procedure MOpenDriveClick(Sender: TObject);
procedure MKeyHelpClick(Sender: TObject);
procedure MAboutClick(Sender: TObject);
procedure MLanguageClick(Sender: TObject);
procedure MAspectClick(Sender: TObject);
procedure MOptionsClick(Sender: TObject);
procedure BPrevNextClick(Sender: TObject);
procedure MShowPlaylistClick(Sender: TObject);
procedure BStopClick(Sender: TObject);
procedure SeekBarMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure VolSliderMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure VolSliderMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure VolSliderMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BMuteClick(Sender: TObject);
procedure MStreamInfoClick(Sender: TObject);
procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure DisplayMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DisplayClick(Sender: TObject);
procedure DisplayDblClick(Sender: TObject);
procedure DisplayMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
procedure DisplayMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MPopupPopup(Sender: TObject);
procedure MPCtrlClick(Sender: TObject);
procedure LStatusClick(Sender: TObject);
procedure VolBoostClick(Sender: TObject);
procedure MExpandClick(Sender: TObject);
procedure MctrlClick(Sender: TObject);
procedure Hide_menuClick(Sender: TObject);
procedure ToggleAlwaysOnTop(Sender: TObject);
procedure MLoadsubClick(Sender: TObject);
procedure MSubfontClick(Sender: TObject);
procedure MKaspectClick(Sender: TObject);
procedure LTimeClick(Sender: TObject);
procedure MWheelControlClick(Sender: TObject);
procedure MIntroClick(Sender: TObject);
procedure MEndClick(Sender: TObject);
procedure MSIEClick(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MOpenDirClick(Sender: TObject);
procedure MEqualizerClick(Sender: TObject);
procedure MQuitClick(Sender: TObject);
procedure MChannelsClick(Sender: TObject);
procedure MFlipClick(Sender: TObject);
procedure MMirrorClick(Sender: TObject);
procedure MRotateClick(Sender: TObject);
procedure MSpdifClick(Sender: TObject);
procedure MSEqualizerClick(Sender: TObject);
procedure MLoadAudioClick(Sender: TObject);
procedure MSoftVolClick(Sender: TObject);
procedure MUloadAudioClick(Sender: TObject);
procedure VolImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MScale0Click(Sender: TObject);
procedure MPanClick(Sender: TObject);
procedure MPostprocClick(Sender: TObject);
procedure MUseASSClick(Sender: TObject);
procedure MOneLoopClick(Sender: TObject);
procedure MLoopAllClick(Sender: TObject);
procedure MShuffleClick(Sender: TObject);
procedure MAudioDelay2Click(Sender: TObject);
procedure MSubDelay2Click(Sender: TObject);
procedure MLoadlyricClick(Sender: TObject);
procedure MUUniClick(Sender: TObject);
procedure MSubScale2Click(Sender: TObject);
procedure MSCSClick(Sender: TObject);
procedure MFClearClick(Sender: TObject);
procedure MOpenDevicesClick(Sender: TObject);
procedure MdownloadsubtitleClick(Sender: TObject);
procedure MDownloadLyricClick(Sender: TObject);
procedure SSDClick(Sender: TObject);
procedure more1Click(Sender: TObject);
procedure MTMClick(Sender: TObject);
private
{ Private declarations }
FirstShow, Seeking, CV, MV: boolean;
WStyle: longint; WheelRolled: boolean;
FS_PX, FS_PY, FS_SX, FS_SY, lm, lw, lh, SeekMouseX, ViewMode: integer;
HideMouseAt, UpdateSeekBarAt: Cardinal; //,ScreenSaverActive:Cardinal;
procedure FormDropFiles(var msg: TMessage); message WM_DROPFILES;
procedure Init_MOpenDrive;
procedure Init_MLanguage;
procedure FormGetMinMaxInfo(var msg: TMessage); message WM_GETMINMAXINFO;
procedure FormMove(var msg: TMessage); message WM_MOVE;
procedure FormWantSpecialKey(var msg: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
procedure PassMsg(var msg: Tmessage); message $0401;
procedure HandleLog(var msg: Tmessage); message $0402;
public
{ Public declarations }
procedure UpdateMRF;
procedure FixSize;
procedure SetupPlay;
procedure SetupStop;
procedure UpdateSeekBar;
procedure Unpaused;
procedure VideoSizeChanged;
procedure DoOpen(const URL, DisplayName: widestring);
procedure SetFullscreen(Mode: boolean);
procedure SetCompact(Mode: boolean);
procedure NextAudio;
procedure NextMonitor;
procedure NextVideo;
procedure NextSub;
procedure NextSubCP;
procedure NextAspect;
procedure NextAngle;
procedure NextOnTop;
procedure NextFile(Direction: integer; ExitState: TPlaybackState);
procedure UpdateStatus;
procedure UpdateParams;
procedure UpdateTime;
procedure UpdateCaption;
procedure UpdateVolSlider;
procedure SetVolumeRel(Increment: integer);
procedure UpdateDockedWindows;
procedure Localize;
procedure SetCtrlV(Mode: boolean);
procedure SetMenuBarV(Mode: boolean);
procedure SetMouseV(Mode: boolean);
procedure UpdateMenuEV(Mode: boolean);
procedure UpdateMenuCheck;
procedure CreateParams(var Params: TCreateParams); override;
end;
TDDEnumCallbackEx = function(lpGuid: PGUID; lpDriverDescription, lpDriverName: PChar; lpContext: pointer; hm: HMONITOR): LongBool; stdcall;
TDownSubtitle_CallBackFinish = procedure(number, bad_number: Integer); stdcall;
TDownSubtitle_CallBackW = procedure(const sub_path: PWChar; is_eng, sub_delay: Integer); stdcall;
var MainForm: TMainForm; IsUser32Loaded: THandle = 0; IsSLoaded: THandle = 0;
DownloaderSubtitleW: function(const filepath: PWChar; eng_sub: Boolean; Callback: TDownSubtitle_CallBackW; callbf: TDownSubtitle_CallBackFinish): Integer; stdcall;
UpdateLyricShowForm: function(Handle: THandle; hdcDest: HDC; pptDst: PPoint; _psize: PSize;
hdcSrc: HDC; pptSrc: PPoint; crKey: COLORREF; pblend: PBLENDFUNCTION; dwFlags: DWORD): Boolean; stdcall;
procedure DownSubtitle_CallBackFinish(number, bad_number: integer); stdcall;
procedure DownSubtitle_CallBackW(const sub_path: PWChar; is_eng, sub_delay: Integer); stdcall;
procedure LoadSLibrary;
procedure UnLoadSLibrary;
procedure LoadUser32Library;
procedure UnLoadUser32Library;
implementation
uses Locale, Config, Options, Info, UnRAR, Equalizer, SevenZip, Core, DLyric,
OpenDevice, GDIPAPI, GDIPOBJ, LyricShow, MediaInfoDll;
{$R *.dfm}
function SetThreadExecutionState(esFlags: Cardinal): Cardinal; stdcall; external kernel32;
procedure LoadUser32Library;
begin
if IsUser32Loaded <> 0 then exit;
IsUser32Loaded := Tnt_LoadLibraryW('user32.dll');
if IsUser32Loaded <> 0 then begin
@UpdateLyricShowForm := GetProcAddress(IsUser32Loaded, 'UpdateLayeredWindow');
end;
end;
procedure UnLoadUser32Library;
begin
if IsUser32Loaded <> 0 then begin
FreeLibrary(IsUser32Loaded);
IsUser32Loaded := 0;
UpdateLyricShowForm := nil;
end;
end;
procedure LoadSLibrary;
begin
if IsSLoaded <> 0 then exit;
IsSLoaded := Tnt_LoadLibraryW(sddll);
if IsSLoaded <> 0 then begin
@DownloaderSubtitleW := GetProcAddress(IsSLoaded, 'DownloaderSubtitleW');
end;
end;
procedure UnLoadSLibrary;
begin
if IsSLoaded <> 0 then begin
FreeLibrary(IsSLoaded);
IsSLoaded := 0;
DownloaderSubtitleW := nil;
end;
end;
procedure DownSubtitle_CallBackFinish(number, bad_number: integer); stdcall;
begin
if number > bad_number then dsEnd := true;
end;
procedure DownSubtitle_CallBackW(const sub_path: PWChar; is_eng, sub_delay: Integer); stdcall;
var s, i: integer; j: WideString;
begin
VobFileCount := 0; s := 0;
Loadsub := 1; j := Tnt_WideLowerCase(WideExtractFileExt(sub_path));
if j = '.idx' then begin
j := GetFileName(sub_path);
if not WideFileExists(j + '.sub') then j := loadArcSub(sub_path);
if j <> '' then begin
inc(VobFileCount);
if VobFileCount = 1 then begin
Vobfile := j; LoadVob := 1; Restart;
end;
end;
end
else begin
i := CheckInfo(MediaType, j);
if (i > -1) and (i <= ZipTypeCount) then begin
if IsLoaded(j) then begin
j := ExtractSub(sub_path, playlist.FindPW(sub_path));
if j <> '' then begin
inc(VobFileCount);
if VobFileCount = 1 then begin
Vobfile := j; LoadVob := 1; Restart;
end;
end;
end;
end
else begin
j := sub_path;
if (not IsWideStringMappableToAnsi(j)) or (pos(',', j) > 0) then j := WideExtractShortPathName(j);
if pos(j, substring) = 0 then begin
if not Win32PlatformIsUnicode then begin
Loadsub := 2; Loadsrt := 2;
AddChain(s, substring, EscapeParam(j));
end
else
SendCommand('sub_load ' + Tnt_WideStringReplace(EscapeParam(j), '\', '/', [rfReplaceAll]));
end;
end;
end;
if (not Win32PlatformIsUnicode) and (s > 0) then Restart;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
//AllocConsole;
randomize;
{$IFDEF VER150}
// some fixes for Delphi>=7 VCLs
OPanel.ParentBackground := False; IPanel.ParentBackground := False;
PStatus.ParentBackground := False; SeekBar.ParentBackground := False;
SkipBar.ParentBackground := False; BackBar.ParentBackground := False;
VolSlider.ParentBackground := False; SeekBarSlider.ParentBackground := False;
{$ENDIF}
CurMonitor := Screen.MonitorFromWindow(Handle);
if CurMonitor = nil then CurMonitor := Screen.Monitors[0];
MonitorW := CurMonitor.Width; MonitorH := CurMonitor.Height;
MonitorID := CurMonitor.MonitorNum;
FirstShow := true; AutoQuit := false; ViewMode := 0;
HideMouseAt := 0; UpdateSeekBarAt := 0; PlayMsgAt := 0;
WantFullscreen := false; WantCompact := false;
Constraints.MinWidth := Width; Constraints.MinHeight := Height;
Load(HomeDir + 'autorun.inf', 0); Load(HomeDir + DefaultFileName, 0);
if subcode = '' then subcode := 'CP' + IntToStr(LCIDToCodePage(LOCALE_USER_DEFAULT)); //AnsiCodePage
SSD.Caption := subcode; SSD.Checked := True;
UpdateVolSlider;
if Wid and Win32PlatformIsUnicode and ds then begin
SetWindowLong(Handle, GWL_STYLE, DWORD(GetWindowLong(Handle, GWL_STYLE)) or WS_SIZEBOX or WS_MAXIMIZEBOX);
Opanel.Visible := true; Logo.Visible := true; MFullscreen.Visible := true;
MCompact.Visible := true; MPFullscreen.Visible := true; MMaxW.Visible := true;
Hide_menu.Visible := true; Mctrl.Visible := true; MPCtrl.Visible := true; MPMaxW.Visible := true;
MPCompact.Visible := true; BFullscreen.Enabled := true; BCompact.Enabled := true;
if EW < OPanel.Width then EW := OPanel.Width;
if RS then Width := Width - OPanel.Width + EW;
end;
Left := CurMonitor.Left + (CurMonitor.Width - Width) div 2;
if RP then Left := EL;
if Wid and Win32PlatformIsUnicode then begin
if ds then begin
if RS then begin
if EH < defaultHeight then EH := defaultHeight;
Height := MWC + MenuBar.Height + CPanel.Height + Width - OPanel.Width + EH;
Top := CurMonitor.Top + (CurMonitor.Height - Height) div 2;
end
else begin
Top := CurMonitor.Top + (CurMonitor.Height - defaultHeight) div 2 - 60;
Height := defaultHeight;
end;
end
else Top := CurMonitor.Top + (CurMonitor.Height - Height) div 2;
if RP then Top := ET;
end
else Top := CurMonitor.Top + CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top - Height;
if RFScr then begin
OPanel.PopupMenu := nil; IPanel.PopupMenu := nil;
end
else begin
OPanel.PopupMenu := MPopup; IPanel.PopupMenu := MPopup;
end;
Init_MLanguage; TeeGDIPlusStartup; LoadUser32Library;
dlod := dlod and (GdipHandle > 0) and Assigned(UpdateLyricShowForm);
with Logo do ControlStyle := ControlStyle + [csOpaque];
with IPanel do ControlStyle := ControlStyle + [csOpaque];
MOSD.Items[OSDLevel].Checked := true; OSDMenu.Items[OSDLevel].Checked := true;
if OnTop = 1 then SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
// SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,@ScreenSaverActive, 0);
// SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,0,nil, 0);
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
procArc := false;
UpdateMRF;
ForceStop; ClearTmpFiles(TempDir);
// SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, ScreenSaverActive, nil, 0);
Config.Save(HomeDir + DefaultFileName, 1);
UnLoadRarLibrary; UnLoadZipLibrary; UnLoad7zLibrary;
UnLoadShell32Library; UnLoadDsLibrary;
UnLoadSLibrary; UnLoadCLibrary; UnLoadUser32Library;
UnLoadMediaInfoLibrary;
FontPaths.Free; SetErrorMode(0);
end;
procedure TMainForm.FormShow(Sender: TObject);
var i, PCount: integer; FileName: WideString; IsFirst: boolean;
t: TTntMenuItem;
begin
UpdateDockedWindows;
if FirstShow then begin
FirstShow := false;
if not Win32PlatformIsUnicode then begin
MPause.Visible := false; MPPause.Visible := false;
BPause.Enabled := false;
end;
CurMonitor := Screen.MonitorFromWindow(Handle);
if CurMonitor = nil then CurMonitor := Screen.Monitors[0];
MonitorW := CurMonitor.Width; MonitorH := CurMonitor.Height;
MonitorID := CurMonitor.MonitorNum;
if Width > MonitorW then Width := MonitorW; if Height > MonitorH then Height := MonitorH;
if (Left < CurMonitor.Left) or ((Left + Width) > (CurMonitor.Left + CurMonitor.Width)) then
Left := CurMonitor.Left + (CurMonitor.Width - Width) div 2;
if (Top < CurMonitor.Top) or ((Top + Height) > (CurMonitor.Top + CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top)) then begin
if Wid and Win32PlatformIsUnicode then
Top := CurMonitor.Top + (CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top - Height) div 2
else Top := CurMonitor.Top + CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top - Height;
end;
for i := 0 to Screen.MonitorCount - 1 do begin
t := TTntMenuItem.Create(MTM);
t.Caption := IntToStr(i); t.Tag := i; t.GroupIndex := $0A;
t.RadioItem := true; t.OnClick := MTMClick;
MTM.Add(t);
end;
MTM.Items[CurMonitor.MonitorNum].Checked := true;
ActivateLocale(DefaultLocale); DragAcceptFiles(Handle, true);
Application.ProcessMessages;
if WideParamStr(1) <> '' then begin
PCount := WideParamCount; IsFirst := true;
for i := 1 to PCount do begin
FileName := WideParamStr(i);
if not CheckOption(FileName) then begin
if IsFirst then begin
PClear := true; EndOpenDir := true; IsFirst := false;
end;
if WideDirectoryExists(FileName) then Playlist.AddDirectory(FileName, false)
else Playlist.AddFiles(FileName, false);
end;
end;
end
else begin
if AutoPlay then begin
PClear := true; EndOpenDir := true;
Playlist.AddDirectory('.', false);
end;
end;
Playlist.Changed;
end;
end;
procedure TMainForm.FormHide(Sender: TObject);
begin
DragAcceptFiles(Handle, false);
end;
procedure TMainForm.FormDropFiles(var msg: TMessage);
var hDrop: THandle; fnbuf, j, t: widestring; k: boolean;
i, DropCount, s, a: integer; FList: TWStringList;
tw: array[0..1024] of wideChar; ta: array[0..1024] of Char;
begin
hDrop := msg.wParam;
if Win32PlatformIsUnicode then DropCount := DragQueryFileW(hDrop, cardinal(-1), nil, 0)
else DropCount := DragQueryFile(hDrop, cardinal(-1), nil, 0);
VobFileCount := 0; s := 0;
FList := TWStringList.Create;
for i := 0 to DropCount - 1 do begin
if Win32PlatformIsUnicode then begin
DragQueryFileW(hDrop, i, tw, 1024); fnbuf := tw;
end
else begin
DragQueryFile(hDrop, i, ta, 1024); fnbuf := WideString(ta);
end;
FList.Add(fnbuf);
end;
FList.SortStr(plist.mysort);
for i := 0 to DropCount - 1 do begin
fnbuf := FList[i];
if WideDirectoryExists(fnbuf) then begin
if i = 0 then begin PClear := true; EndOpenDir := true; end;
Playlist.AddDirectory(fnbuf, false);
end
else begin
j := Tnt_WideLowerCase(WideExtractFileExt(fnbuf));
a := CheckInfo(MediaType, j);
if FilterDrop then k := a > ZipTypeCount
else k := (CheckInfo(SubType, j) = -1) and ((a = -1) or (a > ZipTypeCount));
if k then begin
if i = 0 then begin PClear := true; EndOpenDir := true; end;
Playlist.AddFiles(fnbuf, false);
end
else begin
if j = '.idx' then begin
if Running and HaveVideo then begin
j := GetFileName(fnbuf); Loadsub := 1;
if not WideFileExists(j + '.sub') then j := loadArcSub(fnbuf);
if j <> '' then begin
inc(VobFileCount);
if VobFileCount = 1 then begin
Vobfile := j; LoadVob := 1; Restart;
end;
end;
end;
end
else begin
if (a > -1) and (a <= ZipTypeCount) then begin
if IsLoaded(j) then begin
TmpPW := playlist.FindPW(fnbuf);
if AddMovies(fnbuf, TmpPW, false, false) > 0 then begin //因为AddDir使用多线程,所以不能扰乱TmpPW,就不修改TmpPW了
if i = 0 then begin PClear := true; EndOpenDir := true; end;
AddMovies(fnbuf, TmpPW, true, false);
end;
if Running and HaveVideo then begin
Loadsub := 1;
t := ExtractSub(fnbuf, TmpPW);
if t <> '' then begin
inc(VobFileCount);
if VobFileCount = 1 then begin
Vobfile := t; LoadVob := 1; Restart;
end;
end;
end;
if HaveLyric = 0 then ExtractLyric(fnbuf, TmpPW);
end;
end
else begin
if j = '.lrc' then begin
{j:=WideExtractFileName(MediaURL);
j:=Tnt_WideLowerCase(GetFileName(j));
t:=WideExtractFileName(fnbuf);
t:=Tnt_WideLowerCase(GetFileName(t));
if j=t then }
if HaveLyric = 0 then Lyric.ParseLyric(fnbuf);
end
else if Running then begin
Loadsub := 1;
t := fnbuf;
if (not IsWideStringMappableToAnsi(t)) or (pos(',', t) > 0) then t := WideExtractShortPathName(t);
if pos(t, substring) = 0 then begin
if not Win32PlatformIsUnicode then begin
Loadsub := 2; Loadsrt := 2;
AddChain(s, substring, EscapeParam(t));
end
else
SendCommand('sub_load ' + Tnt_WideStringReplace(EscapeParam(t), '\', '/', [rfReplaceAll]));
end;
end;
end;
end;
end;
end;
end;
DragFinish(hDrop);
FList.Free;
Playlist.Changed;
if (not Win32PlatformIsUnicode) and (s > 0) then Restart;
msg.Result := 0;
end;
procedure TMainForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WinClassName := 'hcb428';
end;
procedure TMainForm.HandleLog(var msg: TMessage);
begin
if Boolean(Msg.wParam) then begin
HandleInputLine(PString(Msg.lParam)^); dispose(PString(Msg.lParam));
end;
end;
procedure TMainForm.PassMsg(var msg: Tmessage);
var OpenFileName: WideString; t: string;
begin
if not Win32PlatformIsUnicode then begin
SetLength(t, msg.LParam);
GlobalGetAtomName(msg.WParam, PChar(t), msg.LParam + 1);
OpenFileName := WideString(t);
end
else begin
SetLength(OpenFileName, msg.LParam);
GlobalGetAtomNameW(msg.WParam, PWChar(OpenFileName), msg.LParam + 1);
end;
GlobalDeleteAtom(msg.WParam);
if not CheckOption(OpenFileName) then begin
if not HaveMsg then begin
PClear := true; EndOpenDir := true; HaveMsg := true;
if IsIconic(Application.Handle) then Application.Restore
else Application.BringToFront;
SetForegroundWindow(Application.Handle);
end;
if WideDirectoryExists(OpenFileName) then Playlist.AddDirectory(OpenFileName, true)
else Playlist.AddFiles(OpenFileName, true);
Playlist.Changed;
end;
end;
procedure TMainForm.DoOpen(const URL, DisplayName: widestring);
begin
ForceStop;
Sleep(50); // wait for the processing threads to finish
Application.ProcessMessages; // let the VCL process the finish messages
if Firstrun then MediaURL := URL; //MakeURL(URL,DisplayURL);
DisplayURL := DisplayName;
UpdateCaption;
FirstOpen := true;
Start;
end;
procedure TMainForm.BPlayClick(Sender: TObject);
begin
if BPause.Down then SendCommand('pause')
else if not Running then NextFile(0, psPlaying);
BPlay.Down := Running;
end;
procedure TMainForm.BPauseClick(Sender: TObject);
begin
BPause.Down := True;
if core.Status = sPaused then SendCommand('frame_step')
else SendCommand('pause');
end;
procedure TMainForm.Unpaused;
begin
if core.Status = sPaused then begin
BPause.Down := false; BPlay.Down := true;
core.Status := sPlaying; UpdateStatus;
SendCommand('set_property mute 0');
end;
end;
procedure TMainForm.UpdateVolSlider;
begin
if Volume < 0 then Volume := 0;
if (Volume > 100) and (not SoftVol) then Volume := 100;
if Volume > 1000 then Volume := 1000;
if Volume > 100 then begin
VolBoost.Visible := True;
VolBoost.Caption := IntToStr(Volume) + '%';
end
else begin
VolBoost.Visible := False;
VolSlider.Left := Volume * (VolFrame.ClientWidth - VolSlider.Width) div 100;
end;
end;
procedure TMainForm.SetVolumeRel(Increment: integer);
begin
if mute then exit;
if (Volume > 100) or ((Volume = 100) and (Increment > 0))
then Increment := Increment * 10 div 3; // bigger volume change steps if >100%
inc(Volume, Increment);
UpdateVolSlider;
SendVolumeChangeCommand(Volume);
end;
procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if OptionsForm.HotKeyToOldKey(Shift, Key) = nil then begin
Key := 0; Shift := [];
end
else HotKeyDown(Sender, Key, Shift);
end;
procedure TMainForm.HotKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var i, j: integer; t: TMenuItem;
procedure HandleCommand(const Command: string); begin
if not Win32PlatformIsUnicode then exit;
SendCommand(Command);
end;
procedure HandleSeekCommand(const Command: string); begin
if not Win32PlatformIsUnicode then exit;
if core.Status = sPaused then SendCommand(Command)
else begin
SendCommand('set_property mute 1');
SendCommand(Command);
SendCommand('set_property mute 0');
end;
if HaveChapters then Sendcommand('get_property chapter');
SendCommand('get_time_length');
end;
begin
if MVideos.Visible then begin
if ssCtrl in Shift then begin
case Key of
VK_RIGHT: if Wid then begin
IPanel.Left := IPanel.Left - 3; IPanel.Width := IPanel.Width + 6;
CBHSA := 2;
end;
VK_LEFT: if Wid then begin
if IPanel.Width = 32 then exit;
IPanel.Width := IPanel.Width - 6;
if IPanel.Width < 32 then IPanel.Width:=32;
IPanel.Left := (OPanel.Width - IPanel.Width) div 2;