-
Notifications
You must be signed in to change notification settings - Fork 13
/
PasLibVlcPlayerUnit.pas
62151 lines (4164 loc) · 200 KB
/
PasLibVlcPlayerUnit.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
(*
*******************************************************************************
* PasLibVlcPlayerUnit.pas - VCL component for VideoLAN libvlc 3.0.5
*
* See copyright notice below.
*
* Last modified: 2019.01.10
*
* author: Robert Jędrzejczyk
* e-mail: [email protected]
* www: http://prog.olsztyn.pl/paslibvlc
*
*
* See PasLibVlcPlayerUnit.txt for change log
*
*******************************************************************************
*
* 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.
*
* Any non-GPL usage of this software or parts of this software is strictly
* forbidden.
*
* The "appropriate copyright message" mentioned in section 2c of the GPLv2
* must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
*
*******************************************************************************
*
* libvlc is part of project VideoLAN
*
* Copyright (c) 1996-2018 VideoLAN Team
*
* For more information about VideoLAN
*
* please visit http://www.videolan.org
*
*)
{$I compiler.inc}
unit PasLibVlcPlayerUnit;
interface
uses
Windows, Messages, Classes, SysUtils, Controls, ExtCtrls, Graphics,
PasLibVlcUnit, PasLibVlcClassUnit;
type
TPasLibVlcMouseEventWinCtrl = class(TWinControl)
private
procedure WMEraseBkgnd(var msg: TWMEraseBkGnd); message WM_ERASEBKGND;
protected
procedure CreateParams(var params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
published
property OnClick;
property OnDblClick;
property OnMouseActivate;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
end;
////////////////////////////////////////////////////////////////////////////////
const
WM_START = WM_USER;
type
TVlcMessage = TMessage;
const
WM_MEDIA_PLAYER_MEDIA_CHANGED = WM_START + Integer(libvlc_MediaPlayerMediaChanged);
WM_MEDIA_PLAYER_NOTHING_SPECIAL = WM_START + Integer(libvlc_MediaPlayerNothingSpecial);
WM_MEDIA_PLAYER_OPENING = WM_START + Integer(libvlc_MediaPlayerOpening);
WM_MEDIA_PLAYER_BUFFERING = WM_START + Integer(libvlc_MediaPlayerBuffering);
WM_MEDIA_PLAYER_PLAYING = WM_START + Integer(libvlc_MediaPlayerPlaying);
WM_MEDIA_PLAYER_PAUSED = WM_START + Integer(libvlc_MediaPlayerPaused);
WM_MEDIA_PLAYER_STOPPED = WM_START + Integer(libvlc_MediaPlayerStopped);
WM_MEDIA_PLAYER_FORWARD = WM_START + Integer(libvlc_MediaPlayerForward);
WM_MEDIA_PLAYER_BACKWARD = WM_START + Integer(libvlc_MediaPlayerBackward);
WM_MEDIA_PLAYER_END_REACHED = WM_START + Integer(libvlc_MediaPlayerEndReached);
WM_MEDIA_PLAYER_ENCOUNTERED_ERROR = WM_START + Integer(libvlc_MediaPlayerEncounteredError);
WM_MEDIA_PLAYER_TIME_CHANGED = WM_START + Integer(libvlc_MediaPlayerTimeChanged);
WM_MEDIA_PLAYER_POSITION_CHANGED = WM_START + Integer(libvlc_MediaPlayerPositionChanged);
WM_MEDIA_PLAYER_SEEKABLE_CHANGED = WM_START + Integer(libvlc_MediaPlayerSeekableChanged);
WM_MEDIA_PLAYER_PAUSABLE_CHANGED = WM_START + Integer(libvlc_MediaPlayerPausableChanged);
WM_MEDIA_PLAYER_TITLE_CHANGED = WM_START + Integer(libvlc_MediaPlayerTitleChanged);
WM_MEDIA_PLAYER_SNAPSHOT_TAKEN = WM_START + Integer(libvlc_MediaPlayerSnapshotTaken);
WM_MEDIA_PLAYER_LENGTH_CHANGED = WM_START + Integer(libvlc_MediaPlayerLengthChanged);
WM_MEDIA_PLAYER_VOUT_CHANGED = WM_START + Integer(libvlc_MediaPlayerVout);
WM_MEDIA_PLAYER_SCRAMBLED_CHANGED = WM_START + Integer(libvlc_MediaPlayerScrambledChanged);
WM_MEDIA_PLAYER_CORKED = WM_START + Integer(libvlc_MediaPlayerCorked);
WM_MEDIA_PLAYER_UNCORKED = WM_START + Integer(libvlc_MediaPlayerUncorked);
WM_MEDIA_PLAYER_MUTED = WM_START + Integer(libvlc_MediaPlayerMuted);
WM_MEDIA_PLAYER_UNMUTED = WM_START + Integer(libvlc_MediaPlayerUnmuted);
WM_MEDIA_PLAYER_AUDIO_VOLUME = WM_START + Integer(libvlc_MediaPlayerAudioVolume);
WM_MEDIA_PLAYER_ES_ADDED = WM_START + Integer(libvlc_MediaPlayerESAdded);
WM_MEDIA_PLAYER_ES_DELETED = WM_START + Integer(libvlc_MediaPlayerESDeleted);
WM_MEDIA_PLAYER_ES_SELECTED = WM_START + Integer(libvlc_MediaPlayerESSelected);
WM_MEDIA_PLAYER_AUDIO_DEVICE = WM_START + Integer(libvlc_MediaPlayerAudioDevice);
WM_MEDIA_PLAYER_CHAPTER_CHANGED = WM_START + Integer(libvlc_MediaPlayerChapterChanged);
WM_RENDERED_DISCOVERED_ITEM_ADDED = WM_START + Integer(libvlc_RendererDiscovererItemAdded);
WM_RENDERED_DISCOVERED_ITEM_DELETED = WM_START + Integer(libvlc_RendererDiscovererItemDeleted);
type
TPasLibVlcPlayerState = (plvPlayer_NothingSpecial, plvPlayer_Opening, plvPlayer_Buffering, plvPlayer_Playing, plvPlayer_Paused, plvPlayer_Stopped, plvPlayer_Ended, plvPlayer_Error);
type
TPasLibVlcPlayerMouseEventsHandler = (mehComponent, mehVideoLAN);
type
TNotifyPlayerEvent = procedure(p_event: libvlc_event_t_ptr; data: Pointer) of object;
TNotifySeekableChanged = procedure(Sender: TObject; val: Boolean) of object;
TNotifyPausableChanged = procedure(Sender: TObject; val: Boolean) of object;
TNotifyTitleChanged = procedure(Sender: TObject; title: Integer) of object;
TNotifySnapshotTaken = procedure(Sender: TObject; fileName: string) of object;
TNotifyTimeChanged = procedure(Sender: TObject; time: Int64) of object;
TNotifyLengthChanged = procedure(Sender: TObject; time: Int64) of object;
TNotifyPositionChanged = procedure(Sender: TObject; position: Single) of object;
TNotifyMediaChanged = procedure(Sender: TObject; mrl: string) of object;
TNotifyVideoOutChanged = procedure(Sender: TObject; video_out: Integer) of object;
TNotifyScrambledChanged = procedure(Sender: TObject; scrambled: Integer) of object;
TNotifyAudioVolumeChanged = procedure(Sender: TObject; volume: Single) of object;
TNotifyMediaPlayerEsAdded = procedure(Sender: TObject; i_type: libvlc_track_type_t; i_id: Integer) of object;
TNotifyMediaPlayerEsDeleted = procedure(Sender: TObject; i_type: libvlc_track_type_t; i_id: Integer) of object;
TNotifyMediaPlayerEsSelected = procedure(Sender: TObject; i_type: libvlc_track_type_t; i_id: Integer) of object;
TNotifyMediaPlayerAudioDevice = procedure(Sender: TObject; audio_device: string) of object;
TNotifyMediaPlayerChapterChanged = procedure(Sender: TObject; chapter: Integer) of object;
TNotifyRendererDiscoveredItemAdded = procedure(Sender: TObject; item: libvlc_renderer_item_t_ptr) of object;
TNotifyRendererDiscoveredItemDeleted = procedure(Sender: TObject; item: libvlc_renderer_item_t_ptr) of object;
TPasLibVlcPlayer = class;
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
TPasLibVlcPlayer = class(TCustomPanel)
private
FVLC: TPasLibVlc;
p_mi: libvlc_media_player_t_ptr;
p_mi_ev_mgr: libvlc_event_manager_t_ptr;
//
FError: string;
FMute: Boolean;
FVideoOutput: TVideoOutput;
FAudioOutput: TAudioOutput;
FTitleShow: Boolean;
FTitleShowPos: TPasLibVlcTitlePosition;
FTitleShowTimeOut: LongWord;
FSnapshotFmt: string;
FSnapshotPrv: Boolean;
FVideoOnTop: Boolean;
FUseOverlay: Boolean;
FSpuShow: Boolean;
FOsdShow: Boolean;
FViewTeleText: Boolean;
FDeinterlaceFilter: TDeinterlaceFilter;
FDeinterlaceMode: TDeinterlaceMode;
FLastAudioOutput: WideString;
FLastAudioOutputDeviceId: WideString;
// events handlers
FOnMediaPlayerMediaChanged: TNotifyMediaChanged;
FOnMediaPlayerNothingSpecial: TNotifyEvent;
FOnMediaPlayerOpening: TNotifyEvent;
FOnMediaPlayerBuffering: TNotifyEvent;
FOnMediaPlayerPlaying: TNotifyEvent;
FOnMediaPlayerPaused: TNotifyEvent;
FOnMediaPlayerStopped: TNotifyEvent;
FOnMediaPlayerForward: TNotifyEvent;
FOnMediaPlayerBackward: TNotifyEvent;
FOnMediaPlayerEndReached: TNotifyEvent;
FOnMediaPlayerEncounteredError: TNotifyEvent;
FOnMediaPlayerTimeChanged: TNotifyTimeChanged;
FOnMediaPlayerPositionChanged: TNotifyPositionChanged;
FOnMediaPlayerSeekableChanged: TNotifySeekableChanged;
FOnMediaPlayerPausableChanged: TNotifyPausableChanged;
FOnMediaPlayerTitleChanged: TNotifyTitleChanged;
FOnMediaPlayerSnapshotTaken: TNotifySnapshotTaken;
FOnMediaPlayerLengthChanged: TNotifyLengthChanged;
FOnMediaPlayerVideoOutChanged: TNotifyVideoOutChanged;
FOnMediaPlayerScrambledChanged: TNotifyScrambledChanged;
FOnMediaPlayerEvent: TNotifyPlayerEvent;
FOnMediaPlayerCorked: TNotifyEvent;
FOnMediaPlayerUnCorked: TNotifyEvent;
FOnMediaPlayerMuted: TNotifyEvent;
FOnMediaPlayerUnMuted: TNotifyEvent;
FOnMediaPlayerAudioVolumeChanged: TNotifyAudioVolumeChanged;
FOnMediaPlayerEsAdded: TNotifyMediaPlayerEsAdded;
FOnMediaPlayerEsDeleted: TNotifyMediaPlayerEsDeleted;
FOnMediaPlayerEsSelected: TNotifyMediaPlayerEsSelected;
FOnMediaPlayerAudioDevice: TNotifyMediaPlayerAudioDevice;
FOnMediaPlayerChapterChanged: TNotifyMediaPlayerChapterChanged;
FOnRendererDiscoveredItemAdded: TNotifyRendererDiscoveredItemAdded;
FOnRendererDiscoveredItemDeleted: TNotifyRendererDiscoveredItemDeleted;
FUseEvents: boolean;
FMouseEventWinCtrl: TPasLibVlcMouseEventWinCtrl;
FMouseEventsHandler: TPasLibVlcPlayerMouseEventsHandler;
FStartOptions: TStringList;
function GetVlcInstance(): TPasLibVlc;
procedure SetStartOptions(Value: TStringList);
procedure SetMouseEventHandler(aValue: TPasLibVlcPlayerMouseEventsHandler);
procedure SetSnapshotFmt(aFormat: string);
procedure SetSnapshotPrv(aValue: Boolean);
procedure SetSpuShow(aValue: Boolean);
procedure SetOsdShow(aValue: Boolean);
procedure SetVideoOnTop(aValue: Boolean);
procedure SetUseOverlay(aValue: Boolean);
procedure SetViewTeleText(aValue: Boolean);
procedure SetTitleShow(aValue: Boolean);
procedure SetTitleShowPos(aValue: TPasLibVlcTitlePosition);
procedure SetTitleShowTimeOut(aValue: LongWord);
procedure SetDeinterlaceFilter(aValue: TDeinterlaceFilter);
procedure SetDeinterlaceMode(aValue: TDeinterlaceMode);
procedure InternalOnClick(Sender: TObject);
procedure InternalOnDblClick(Sender: TObject);
procedure InternalOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure InternalOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure InternalOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure InternalOnMouseActivate(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y, HitTest: Integer; var MouseActivate: TMouseActivate);
procedure InternalOnMouseEnter(Sender: TObject);
procedure InternalOnMouseLeave(Sender: TObject);
procedure InternalOnMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure InternalOnMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure WmMediaPlayerMediaChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_MEDIA_CHANGED;
procedure WmMediaPlayerNothingSpecial(var m: TVlcMessage); message WM_MEDIA_PLAYER_NOTHING_SPECIAL;
procedure WmMediaPlayerOpening(var m: TVlcMessage); message WM_MEDIA_PLAYER_OPENING;
procedure WmMediaPlayerBuffering(var m: TVlcMessage); message WM_MEDIA_PLAYER_BUFFERING;
procedure WmMediaPlayerPlaying(var m: TVlcMessage); message WM_MEDIA_PLAYER_PLAYING;
procedure WmMediaPlayerPaused(var m: TVlcMessage); message WM_MEDIA_PLAYER_PAUSED;
procedure WmMediaPlayerStopped(var m: TVlcMessage); message WM_MEDIA_PLAYER_STOPPED;
procedure WmMediaPlayerForward(var m: TVlcMessage); message WM_MEDIA_PLAYER_FORWARD;
procedure WmMediaPlayerBackward(var m: TVlcMessage); message WM_MEDIA_PLAYER_BACKWARD;
procedure WmMediaPlayerEndReached(var m: TVlcMessage); message WM_MEDIA_PLAYER_END_REACHED;
procedure WmMediaPlayerEncounteredError(var m: TVlcMessage); message WM_MEDIA_PLAYER_ENCOUNTERED_ERROR;
procedure WmMediaPlayerTimeChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_TIME_CHANGED;
procedure WmMediaPlayerPositionChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_POSITION_CHANGED;
procedure WmMediaPlayerSeekableChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_SEEKABLE_CHANGED;
procedure WmMediaPlayerPausableChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_PAUSABLE_CHANGED;
procedure WmMediaPlayerTitleChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_TITLE_CHANGED;
procedure WmMediaPlayerSnapshotTaken(var m: TVlcMessage); message WM_MEDIA_PLAYER_SNAPSHOT_TAKEN;
procedure WmMediaPlayerLengthChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_LENGTH_CHANGED;
procedure WmMediaPlayerVOutChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_VOUT_CHANGED;
procedure WmMediaPlayerScrambledChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_SCRAMBLED_CHANGED;
procedure WmMediaPlayerCorked(var m: TVlcMessage); message WM_MEDIA_PLAYER_CORKED;
procedure WmMediaPlayerUnCorked(var m: TVlcMessage); message WM_MEDIA_PLAYER_UNCORKED;
procedure WmMediaPlayerMuted(var m: TVlcMessage); message WM_MEDIA_PLAYER_MUTED;
procedure WmMediaPlayerUnMuted(var m: TVlcMessage); message WM_MEDIA_PLAYER_UNMUTED;
procedure WmMediaPlayerAudioVolumeChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_AUDIO_VOLUME;
procedure WmMediaPlayerEsAdded(var m: TVlcMessage); message WM_MEDIA_PLAYER_ES_ADDED;
procedure WmMediaPlayerEsDeleted(var m: TVlcMessage); message WM_MEDIA_PLAYER_ES_DELETED;
procedure WmMediaPlayerEsSelected(var m: TVlcMessage); message WM_MEDIA_PLAYER_ES_SELECTED;
procedure WmMediaPlayerAudioDevice(var m: TVlcMessage); message WM_MEDIA_PLAYER_AUDIO_DEVICE;
procedure WmMediaPlayerChapterChanged(var m: TVlcMessage); message WM_MEDIA_PLAYER_CHAPTER_CHANGED;
procedure WmRendererDiscoveredItemAdded(var m: TVlcMessage); message WM_RENDERED_DISCOVERED_ITEM_ADDED;
procedure WmRendererDiscoveredItemDeleted(var m: TVlcMessage); message WM_RENDERED_DISCOVERED_ITEM_DELETED;
procedure SetHideCursor(const Value: Boolean);
function GetHideCursor: Boolean;
protected
procedure WMEraseBkgnd(var msg: TWMEraseBkGnd); message WM_ERASEBKGND;
procedure CreateParams(var params: TCreateParams); override;
procedure SetHwnd();
procedure DestroyPlayer();
procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT;
procedure WMResize(var Message: TMessage); message WM_SIZE;
procedure PlayContinue(audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure PlayContinue(const mediaOptions: array of string; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetDeinterlaceModeName(): WideString;
function GetPlayerHandle(): libvlc_media_player_t_ptr;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
procedure PlayInWindow(newWindow: TWinControl = NIL; aOut: WideString = ''; aOutDeviceId: WideString = '');
procedure Play(var media: TPasLibVlcMedia; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure Play(mrl: WideString; const mediaOptions: array of string; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure Play(stm: TStream; const mediaOptions: array of string; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure PlayNormal(mrl: WideString; const mediaOptions: array of string; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure PlayYoutube(mrl: WideString; const mediaOptions: array of string; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000; youtubeTimeout: Cardinal = 10000); overload;
procedure Play(mrl: WideString; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure Play(stm: TStream; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure PlayNormal(mrl: WideString; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000); overload;
procedure PlayYoutube(mrl: WideString; audioOutput: WideString = ''; audioOutputDeviceId: WideString = ''; audioSetTimeOut: Cardinal = 1000; youtubeTimeout: Cardinal = 10000); overload;
function GetMediaMrl(): string;
procedure Pause();
procedure Resume();
function IsPlay(): Boolean;
function IsPause(): Boolean;
procedure Stop();
function GetState(): TPasLibVlcPlayerState;
function GetStateName(): string;
function CanPlay(): Boolean;
function CanPause(): Boolean;
function CanSeek(): Boolean;
function HasVout(): Boolean;
function IsScrambled(): Boolean;
function Snapshot(fileName: WideString): Boolean; overload;
function Snapshot(fileName: WideString; width, height: LongWord): Boolean; overload;
procedure NextFrame();
procedure SetPlayRate(rate: Integer);
procedure SetFullScreen(aValue: Boolean);
function GetPlayRate(): Integer;
function GetVideoWidth(): LongInt;
function GetVideoHeight(): LongInt;
function GetVideoDimension(var width, height: LongWord): Boolean;
function GetVideoScaleInPercent(): Single;
function GetVideoAspectRatio: string; overload;
function GetVideoAspectRatioType: TVideoRatio; overload;
function GetVideoSampleAspectRatio(var sar_num, sar_den: LongWord): Boolean; overload;
function GetVideoSampleAspectRatio(): Single; overload;
procedure SetVideoScaleInPercent(newScaleInPercent: Single);
procedure SetVideoAspectRatio(newAspectRatio: string);
function GetVideoLenInMs(): Int64;
function GetVideoLenInMsAlter(): Int64;
function GetVideoPosInMs(): Int64;
function GetVideoLeftInMs(): Int64;
function GetVideoPosInPercent(): Single;
function GetVideoFps(): Single;
procedure SetVideoPosInMs(newPos: Int64);
procedure SetVideoPosInPercent(newPos: Single);
function GetVideoLenStr(fmt: string = 'hh:mm:ss'): string;
function GetVideoPosStr(fmt: string = 'hh:mm:ss'): string;
procedure SetTeleText(page: Integer);
function GetTeleText(): Integer;
function ShowTeleText(): Boolean;
function HideTeleText(): Boolean;
function GetAudioMute(): Boolean;
procedure SetAudioMute(mute: Boolean);
function GetAudioVolume(): Integer;
procedure SetAudioVolume(volumeLevel: Integer);
function GetAudioChannel(): libvlc_audio_output_channel_t;
procedure SetAudioChannel(chanel: libvlc_audio_output_channel_t);
function GetAudioDelay(): Int64;
procedure SetAudioDelay(delay: Int64);
function GetAudioFilterList(return_name_type: Integer = 0): TStringList;
function GetVideoFilterList(return_name_type: Integer = 0): TStringList;
function GetAudioTrackList(): TStringList;
function GetAudioTrackCount(): Integer;
function GetAudioTrackId(): Integer;
procedure SetAudioTrackById(const track_id: Integer);
function GetAudioTrackNo(): Integer;
procedure SetAudioTrackByNo(track_no: Integer);
function GetAudioTrackDescriptionById(const track_id: Integer): WideString;
function GetAudioTrackDescriptionByNo(track_no: Integer): WideString;
function GetAudioOutputList(withDescription: Boolean = FALSE; separator: string = '|'): TStringList;
function GetAudioOutputDeviceList(aOut: string; withDescription: Boolean = FALSE; separator: string = '|'): TStringList;
function GetAudioOutputDeviceEnum(withDescription: Boolean = FALSE; separator: string = '|'): TStringList;
function SetAudioOutput(aOut: string): Boolean;
procedure SetAudioOutputDevice(aOut: string; aOutDeviceId: string); overload;
procedure SetAudioOutputDevice(aOutDeviceId: string); overload;
{$IFDEF USE_VLC_DEPRECATED_API}
function GetAudioOutputDeviceCount(aOut: WideString): Integer;
function GetAudioOutputDeviceId(aOut: WideString; deviceIdx: Integer): WideString;
function GetAudioOutputDeviceName(aOut: WideString; deviceIdx: Integer): WideString;
{$ENDIF}
function EqualizerGetPresetList(): TStringList;
function EqualizerGetBandCount(): unsigned_t;
function EqualizerGetBandFrequency(bandIndex: unsigned_t): Single;
function EqualizerCreate(APreset: unsigned_t = $FFFF): TPasLibVlcEqualizer;
procedure EqualizerApply(AEqualizer: TPasLibVlcEqualizer);
procedure EqualizerSetPreset(APreset: unsigned_t = $FFFF);
procedure SetVideoAdjustEnable(value: Boolean);
function GetVideoAdjustEnable(): Boolean;
procedure SetVideoAdjustContrast(value: Single);
function GetVideoAdjustContrast(): Single;
procedure SetVideoAdjustBrightness(value: Single);
function GetVideoAdjustBrightness(): Single;
procedure SetVideoAdjustHue(value: Integer);
function GetVideoAdjustHue(): Integer;
procedure SetVideoAdjustSaturation(value: Single);
function GetVideoAdjustSaturation(): Single;
procedure SetVideoAdjustGamma(value: Single);
function GetVideoAdjustGamma(): Single;
function GetVideoChapter(): Integer;
procedure SetVideoChapter(newChapter: Integer);
function GetVideoChapterCount(): Integer;
function GetVideoChapterCountByTitleId(const title_id: Integer): Integer;
function GetVideoSubtitleList(): TStringList;
function GetVideoSubtitleCount(): Integer;
function GetVideoSubtitleId(): Integer;
procedure SetVideoSubtitleById(const subtitle_id: Integer);
function GetVideoSubtitleNo(): Integer;
procedure SetVideoSubtitleByNo(subtitle_no: Integer);
function GetVideoSubtitleDescriptionById(const subtitle_id: Integer): WideString;
function GetVideoSubtitleDescriptionByNo(subtitle_no: Integer): WideString;
procedure SetVideoSubtitleFile(subtitle_file: WideString);
function GetVideoTitleList(): TStringList;
function GetVideoTitleCount(): Integer;
function GetVideoTitleId(): Integer;
procedure SetVideoTitleById(const title_id: Integer);
function GetVideoTitleNo(): Integer;
procedure SetVideoTitleByNo(title_no: Integer);
function GetVideoTitleDescriptionById(const track_id: Integer): WideString;
function GetVideoTitleDescriptionByNo(title_no: Integer): WideString;
// https://wiki.videolan.org/Documentation:Modules/logo/
procedure LogoSetFile(file_name: string);
procedure LogoSetFiles(file_names: array of WideString; delay_ms: Integer = 1000; loop: Boolean = TRUE);
procedure LogoSetPosition(position_x, position_y: Integer); overload;
procedure LogoSetPosition(position: libvlc_position_t); overload;
procedure LogoSetOpacity(opacity: libvlc_opacity_t);
procedure LogoSetDelay(delay_ms: Integer = 1000); // delay before show next logo file, default 1000
procedure LogoSetRepeat(loop: boolean = TRUE);
procedure LogoSetRepeatCnt(loop: Integer = 0);
procedure LogoSetEnable(enable: Integer);
procedure LogoShowFile(file_name: WideString; position_x, position_y: Integer; opacity: libvlc_opacity_t = libvlc_opacity_full); overload;
procedure LogoShowFile(file_name: WideString; position: libvlc_position_t = libvlc_position_top; opacity: libvlc_opacity_t = libvlc_opacity_full); overload;
procedure LogoShowFiles(file_names: array of WideString; position_x, position_y: Integer; opacity: libvlc_opacity_t = libvlc_opacity_full; delay_ms: Integer = 1000; loop: Boolean = TRUE); overload;
procedure LogoShowFiles(file_names: array of WideString; position: libvlc_position_t = libvlc_position_top; opacity: libvlc_opacity_t = libvlc_opacity_full; delay_ms: Integer = 1000; loop: Boolean = TRUE); overload;
procedure LogoHide();
// https://wiki.videolan.org/Documentation:Modules/marq/
procedure MarqueeSetText(marquee_text: WideString);
procedure MarqueeSetPosition(position_x, position_y: Integer); overload;
procedure MarqueeSetPosition(position: libvlc_position_t); overload;
procedure MarqueeSetColor(color: libvlc_video_marquee_color_t);
procedure MarqueeSetFontSize(font_size: Integer);
procedure MarqueeSetOpacity(opacity: libvlc_opacity_t);
procedure MarqueeSetTimeOut(time_out_ms: Integer);
procedure MarqueeSetRefresh(refresh_after_ms: Integer);
procedure MarqueeSetEnable(enable: Integer);
procedure MarqueeShowText(marquee_text: WideString; position_x, position_y: Integer; color: libvlc_video_marquee_color_t = libvlc_video_marquee_color_White; font_size: Integer = libvlc_video_marquee_default_font_size; opacity: libvlc_opacity_t = libvlc_opacity_full; time_out_ms: Integer = 0); overload;
procedure MarqueeShowText(marquee_text: WideString; position: libvlc_position_t = libvlc_position_bottom; color: libvlc_video_marquee_color_t = libvlc_video_marquee_color_White; font_size: Integer = libvlc_video_marquee_default_font_size; opacity: libvlc_opacity_t = libvlc_opacity_full; time_out_ms: Integer = 0); overload;
procedure MarqueeHide();
procedure EventsDisable();
procedure EventsEnable();
procedure UpdateDeInterlace();
procedure UpdateTitleShow();
property VLC: TPasLibVlc read GetVlcInstance;
property LastError: string read FError write FError;
property LastAudioOutput: WideString read FLastAudioOutput;
property LastAudioOutputDeviceId: WideString read FLastAudioOutputDeviceId;
property HideCursor: Boolean read GetHideCursor write SetHideCursor;
published
property Align;
property AlignWithMargins;
property Anchors;
property Color default clBlack;
property Width default 320;
property Height default 240;
property Constraints;
property DragKind;
property DragMode;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Visible;
{$IFDEF DELPHI2005_UP}
property OnAlignPosition;
{$ENDIF}
property OnCanResize;
property OnClick;
property OnConstrainedResize;
{$IFDEF HAS_OnContextPopup}
property OnContextPopup;
{$ENDIF}
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseActivate;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheelUp;
property OnMouseWheelDown;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
property TabOrder;
property TabStop default True;
property SpuShow: Boolean read FSpuShow write SetSpuShow default TRUE;
property OsdShow: Boolean read FOsdShow write SetOsdShow default TRUE;
property TitleShow: Boolean read FTitleShow write SetTitleShow default FALSE;
property TitleShowPos: TPasLibVlcTitlePosition read FTitleShowPos write SetTitleShowPos default plvPosCenter;
property TitleShowTimeOut: LongWord read FTitleShowTimeOut write SetTitleShowTimeOut default 2000;
property VideoOutput: TVideoOutput read FVideoOutput write FVideoOutput default voDefault;
property AudioOutput: TAudioOutput read FAudioOutput write FAudioOutput default aoDefault;
property VideoOnTop: Boolean read FVideoOnTop write SetVideoOnTop default FALSE;
property UseOverlay: Boolean read FUseOverlay write SetUseOverlay default FALSE;
property SnapShotFmt: string read FSnapShotFmt write SetSnapshotFmt;
property SnapshotPrv: Boolean read FSnapShotPrv write SetSnapshotPrv default FALSE;
property DeinterlaceFilter: TDeinterlaceFilter read FDeinterlaceFilter write SetDeinterlaceFilter default deOFF;
property DeinterlaceMode: TDeinterlaceMode read FDeinterlaceMode write SetDeinterlaceMode default dmDISCARD;
property ViewTeletext: Boolean read FViewTeleText write SetViewTeleText default FALSE;
property StartOptions: TStringList read FStartOptions write SetStartOptions;
property OnMediaPlayerEvent: TNotifyPlayerEvent read FOnMediaPlayerEvent write FOnMediaPlayerEvent;
property OnMediaPlayerMediaChanged: TNotifyMediaChanged read FOnMediaPlayerMediaChanged write FOnMediaPlayerMediaChanged;
property OnMediaPlayerNothingSpecial: TNotifyEvent read FOnMediaPlayerNothingSpecial write FOnMediaPlayerNothingSpecial;
property OnMediaPlayerOpening: TNotifyEvent read FOnMediaPlayerOpening write FOnMediaPlayerOpening;
property OnMediaPlayerBuffering: TNotifyEvent read FOnMediaPlayerBuffering write FOnMediaPlayerBuffering;
property OnMediaPlayerPlaying: TNotifyEvent read FOnMediaPlayerPlaying write FOnMediaPlayerPlaying;
property OnMediaPlayerPaused: TNotifyEvent read FOnMediaPlayerPaused write FOnMediaPlayerPaused;
property OnMediaPlayerStopped: TNotifyEvent read FOnMediaPlayerStopped write FOnMediaPlayerStopped;
property OnMediaPlayerForward: TNotifyEvent read FOnMediaPlayerForward write FOnMediaPlayerForward;
property OnMediaPlayerBackward: TNotifyEvent read FOnMediaPlayerBackward write FOnMediaPlayerBackward;
property OnMediaPlayerEndReached: TNotifyEvent read FOnMediaPlayerEndReached write FOnMediaPlayerEndReached;
property OnMediaPlayerEncounteredError: TNotifyEvent read FOnMediaPlayerEncounteredError write FOnMediaPlayerEncounteredError;
property OnMediaPlayerTimeChanged: TNotifyTimeChanged read FOnMediaPlayerTimeChanged write FOnMediaPlayerTimeChanged;
property OnMediaPlayerPositionChanged: TNotifyPositionChanged read FOnMediaPlayerPositionChanged write FOnMediaPlayerPositionChanged;
property OnMediaPlayerSeekableChanged: TNotifySeekableChanged read FOnMediaPlayerSeekableChanged write FOnMediaPlayerSeekableChanged;
property OnMediaPlayerPausableChanged: TNotifyPausableChanged read FOnMediaPlayerPausableChanged write FOnMediaPlayerPausableChanged;
property OnMediaPlayerTitleChanged: TNotifyTitleChanged read FOnMediaPlayerTitleChanged write FOnMediaPlayerTitleChanged;
property OnMediaPlayerSnapshotTaken: TNotifySnapshotTaken read FOnMediaPlayerSnapshotTaken write FOnMediaPlayerSnapshotTaken;
property OnMediaPlayerLengthChanged: TNotifyLengthChanged read FOnMediaPlayerLengthChanged write FOnMediaPlayerLengthChanged;
property OnMediaPlayerVideoOutChanged: TNotifyVideoOutChanged read FOnMediaPlayerVideoOutChanged write FOnMediaPlayerVideoOutChanged;
property OnMediaPlayerScrambledChanged: TNotifyScrambledChanged read FOnMediaPlayerScrambledChanged write FOnMediaPlayerScrambledChanged;
property OnMediaPlayerCorked: TNotifyEvent read FOnMediaPlayerCorked write FOnMediaPlayerCorked;
property OnMediaPlayerUnCorked: TNotifyEvent read FOnMediaPlayerUnCorked write FOnMediaPlayerUnCorked;
property OnMediaPlayerMuted: TNotifyEvent read FOnMediaPlayerMuted write FOnMediaPlayerMuted;
property OnMediaPlayerUnMuted: TNotifyEvent read FOnMediaPlayerUnMuted write FOnMediaPlayerUnMuted;
property OnMediaPlayerAudioVolumeChanged: TNotifyAudioVolumeChanged read FOnMediaPlayerAudioVolumeChanged write FOnMediaPlayerAudioVolumeChanged;
property OnMediaPlayerEsAdded: TNotifyMediaPlayerEsAdded read FOnMediaPlayerEsAdded write FOnMediaPlayerEsAdded;
property OnMediaPlayerEsDeleted: TNotifyMediaPlayerEsDeleted read FOnMediaPlayerEsDeleted write FOnMediaPlayerEsDeleted;
property OnMediaPlayerEsSelected: TNotifyMediaPlayerEsSelected read FOnMediaPlayerEsSelected write FOnMediaPlayerEsSelected;
property OnMediaPlayerAudioDevice: TNotifyMediaPlayerAudioDevice read FOnMediaPlayerAudioDevice write FOnMediaPlayerAudioDevice;
property OnMediaPlayerChapterChanged: TNotifyMediaPlayerChapterChanged read FOnMediaPlayerChapterChanged write FOnMediaPlayerChapterChanged;
property OnRendererDiscoveredItemAdded: TNotifyRendererDiscoveredItemAdded read FOnRendererDiscoveredItemAdded write FOnRendererDiscoveredItemAdded;
property OnRendererDiscoveredItemDeleted: TNotifyRendererDiscoveredItemDeleted read FOnRendererDiscoveredItemDeleted write FOnRendererDiscoveredItemDeleted;
property UseEvents: boolean read FUseEvents write FUseEvents default TRUE;
property MouseEventsHandler: TPasLibVlcPlayerMouseEventsHandler read FMouseEventsHandler write SetMouseEventHandler default mehVideoLAN;
end;
TNotifyMediaListItem = procedure(Sender: TObject; mrl: WideString; item: Pointer; index: Integer) of object;
TPasLibVlcMediaList = class(TComponent)
private
p_ml: libvlc_media_list_t_ptr;
p_mlp: libvlc_media_list_player_t_ptr;
p_ml_ev_mgr: libvlc_event_manager_t_ptr;
p_mlp_ev_mgr: libvlc_event_manager_t_ptr;
FPlayer: TPasLibVlcPlayer;
FError: string;
FOnItemAdded: TNotifyMediaListItem;
FOnWillAddItem: TNotifyMediaListItem;
FOnItemDeleted: TNotifyMediaListItem;
FOnWillDeleteItem: TNotifyMediaListItem;
FOnNextItemSet: TNotifyMediaListItem;
FOnPlayed: TNotifyEvent;
FOnStopped: TNotifyEvent;
procedure SetPlayer(aPlayer: TPasLibVlcPlayer);
procedure InternalHandleEventItemAdded(item: libvlc_media_t_ptr; index: Integer);
procedure InternalHandleEventItemDeleted(item: libvlc_media_t_ptr; index: Integer);
procedure InternalHandleEventWillAddItem(item: libvlc_media_t_ptr; index: Integer);
procedure InternalHandleEventWillDeleteItem(item: libvlc_media_t_ptr; index: Integer);
procedure InternalHandleEventPlayerNextItemSet(item: libvlc_media_t_ptr);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetPlayModeNormal;
procedure SetPlayModeLoop;
procedure SetPlayModeRepeat;
procedure Play();
procedure Pause();
procedure Stop();
procedure Next();
procedure Prev();
function IsPlay(): Boolean;
function IsPause(): Boolean;
function GetState(): TPasLibVlcPlayerState;
function GetStateName(): string;
procedure PlayItem(item: libvlc_media_t_ptr);
procedure Clear();
procedure Add(mrl: WideString); overload;
procedure Add(mrl: WideString; mediaOptions: array of WideString); overload;
function Get(index: Integer): WideString;
function Count(): Integer;
procedure Delete(index: Integer);
procedure Insert(index: Integer; mrl: WideString);
function GetItemAtIndex(index: Integer): libvlc_media_t_ptr;
function IndexOfItem(item: libvlc_media_t_ptr): Integer;
procedure EventsDisable();
procedure EventsEnable();
published
property Player: TPasLibVlcPlayer read FPlayer write SetPlayer;
property LastError: string read FError write FError;
property OnItemAdded: TNotifyMediaListItem read FOnItemAdded write FOnItemAdded;
property OnWillAddItem: TNotifyMediaListItem read FOnWillAddItem write FOnWillAddItem;
property OnItemDeleted: TNotifyMediaListItem read FOnItemDeleted write FOnItemDeleted;
property OnWillDeleteItem: TNotifyMediaListItem read FOnWillDeleteItem write FOnWillDeleteItem;
property OnPlayed: TNotifyEvent read FOnPlayed write FOnPlayed;
property OnStopped: TNotifyEvent read FOnStopped write FOnStopped;
property OnNextItemSet: TNotifyMediaListItem read FOnNextItemSet write FOnNextItemSet;
end;
procedure Register;
implementation
{$R *.RES}
{$IFDEF DELPHI_XE2_UP}
uses
System.AnsiStrings, Math;
{$ENDIF}
{$IFDEF FPC}
procedure RegisterPasLibVlcPlayerUnit;
begin
RegisterComponents('PasLibVlc', [TPasLibVlcPlayer, TPasLibVlcMediaList]);
end;
procedure Register;
begin
RegisterUnit('PasLibVlcPlayerUnit', @RegisterPasLibVlcPlayerUnit);
end;
{$ELSE}
procedure Register;
begin
RegisterComponents('PasLibVlc', [TPasLibVlcPlayer, TPasLibVlcMediaList]);
end;
{$ENDIF}
{$IFNDEF HAS_WS_EX_TRANSPARENT}
const
WS_EX_TRANSPARENT = $20;
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
constructor TPasLibVlcMouseEventWinCtrl.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csOpaque];
end;
procedure TPasLibVlcMouseEventWinCtrl.CreateParams(var params: TCreateParams);
begin
inherited CreateParams(params);
params.ExStyle := params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TPasLibVlcMouseEventWinCtrl.WMEraseBkgnd(var msg: {$IFDEF FPC}TLMEraseBkgnd{$ELSE}TWMEraseBkGnd{$ENDIF});
begin
if (msg.DC <> 0) then
begin
SetBkMode(msg.DC, TRANSPARENT);
FillRect(msg.DC, Rect(0, 0, Width, Height), HBRUSH({$IFDEF FPC}Brush.Reference.Handle{$ELSE}Brush.Handle{$ENDIF}));
end;
msg.result := 1;
end;
////////////////////////////////////////////////////////////////////////////////
procedure lib_vlc_player_event_hdlr(p_event: libvlc_event_t_ptr; data: Pointer); cdecl; forward;
procedure lib_vlc_media_list_event_hdlr(p_event: libvlc_event_t_ptr; data: Pointer); cdecl; forward;
procedure lib_vlc_media_list_player_event_hdlr(p_event: libvlc_event_t_ptr; data: Pointer); cdecl; forward;
////////////////////////////////////////////////////////////////////////////////
constructor TPasLibVlcMediaList.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
p_ml := NIL;
p_mlp := NIL;
p_ml_ev_mgr := NIL;
p_mlp_ev_mgr := NIL;
FPlayer := NIL;
if (csDesigning in ComponentState) then
exit;
end;
destructor TPasLibVlcMediaList.Destroy;
begin
EventsDisable();
Sleep(100);
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_stop(p_mlp);
while (libvlc_media_list_player_is_playing(p_mlp) <> 0) do
begin
Sleep(10);
end;
end;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_release(p_mlp);
end;
if (p_ml <> NIL) then
begin
libvlc_media_list_release(p_ml);
end;
inherited Destroy;
end;
procedure TPasLibVlcMediaList.EventsDisable();
begin
if Assigned(p_mlp_ev_mgr) then
begin
libvlc_event_detach(p_mlp_ev_mgr, libvlc_MediaListPlayerNextItemSet, lib_vlc_media_list_player_event_hdlr, SELF);
libvlc_event_detach(p_mlp_ev_mgr, libvlc_MediaListPlayerStopped, lib_vlc_media_list_player_event_hdlr, SELF);
libvlc_event_detach(p_mlp_ev_mgr, libvlc_MediaListPlayerPlayed, lib_vlc_media_list_player_event_hdlr, SELF);
end;
if Assigned(p_ml_ev_mgr) then
begin
libvlc_event_detach(p_ml_ev_mgr, libvlc_MediaListWillDeleteItem, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_detach(p_ml_ev_mgr, libvlc_MediaListItemDeleted, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_detach(p_ml_ev_mgr, libvlc_MediaListWillAddItem, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_detach(p_ml_ev_mgr, libvlc_MediaListItemAdded, lib_vlc_media_list_event_hdlr, SELF);
end;
p_mlp_ev_mgr := NIL;
p_ml_ev_mgr := NIL;
end;
procedure TPasLibVlcMediaList.EventsEnable();
begin
EventsDisable();
if (p_ml <> NIL) then
begin
p_ml_ev_mgr := libvlc_media_list_event_manager(p_ml);
if Assigned(p_ml_ev_mgr) then
begin
libvlc_event_attach(p_ml_ev_mgr, libvlc_MediaListItemAdded, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_attach(p_ml_ev_mgr, libvlc_MediaListWillAddItem, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_attach(p_ml_ev_mgr, libvlc_MediaListItemDeleted, lib_vlc_media_list_event_hdlr, SELF);
libvlc_event_attach(p_ml_ev_mgr, libvlc_MediaListWillDeleteItem, lib_vlc_media_list_event_hdlr, SELF);
end;
p_mlp_ev_mgr := libvlc_media_list_player_event_manager(p_mlp);
if Assigned(p_mlp_ev_mgr) then
begin
libvlc_event_attach(p_mlp_ev_mgr, libvlc_MediaListPlayerPlayed, lib_vlc_media_list_player_event_hdlr, SELF);
libvlc_event_attach(p_mlp_ev_mgr, libvlc_MediaListPlayerStopped, lib_vlc_media_list_player_event_hdlr, SELF);
libvlc_event_attach(p_mlp_ev_mgr, libvlc_MediaListPlayerNextItemSet, lib_vlc_media_list_player_event_hdlr, SELF);
end;
end;
end;
procedure TPasLibVlcMediaList.SetPlayer(aPlayer: TPasLibVlcPlayer);
begin
FPlayer := aPlayer;
if (csDesigning in ComponentState) then
exit;
if (FPlayer.VLC.Handle <> NIL) then
begin
p_ml := libvlc_media_list_new(FPlayer.VLC.Handle);
p_mlp := libvlc_media_list_player_new(FPlayer.VLC.Handle);
libvlc_media_list_player_set_media_list(p_mlp, p_ml);
EventsEnable();
end;
end;
procedure TPasLibVlcMediaList.SetPlayModeNormal;
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_playback_mode(p_mlp, libvlc_playback_mode_default);
end;
end;
procedure TPasLibVlcMediaList.SetPlayModeLoop;
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_playback_mode(p_mlp, libvlc_playback_mode_loop);
end;
end;
procedure TPasLibVlcMediaList.SetPlayModeRepeat;
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_playback_mode(p_mlp, libvlc_playback_mode_repeat);
end;
end;
procedure TPasLibVlcMediaList.Play;
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_media_player(p_mlp, FPlayer.GetPlayerHandle());
FPlayer.SetHwnd();
libvlc_media_list_player_play(p_mlp);
end;
end;
procedure TPasLibVlcMediaList.PlayItem(item: libvlc_media_t_ptr);
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_media_player(p_mlp, FPlayer.GetPlayerHandle());
FPlayer.SetHwnd();
libvlc_media_list_player_play_item(p_mlp, item);
end;
end;
procedure TPasLibVlcMediaList.Pause();
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_pause(p_mlp);
end;
end;
procedure TPasLibVlcMediaList.Stop();
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
if (libvlc_media_list_player_is_playing(p_mlp) = 1) then
begin
libvlc_media_list_player_stop(p_mlp);
Sleep(50);
while (libvlc_media_list_player_is_playing(p_mlp) = 1) do
begin
Sleep(50);
end;
end;
end;
end;
procedure TPasLibVlcMediaList.Next();
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_media_player(p_mlp, FPlayer.GetPlayerHandle());
FPlayer.SetHwnd();
libvlc_media_list_player_next(p_mlp);
end;
end;
procedure TPasLibVlcMediaList.Prev();
begin
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
libvlc_media_list_player_set_media_player(p_mlp, FPlayer.GetPlayerHandle());
FPlayer.SetHwnd();
libvlc_media_list_player_previous(p_mlp);
end;
end;
function TPasLibVlcMediaList.IsPlay(): Boolean;
begin
Result := FALSE;
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
Result := (libvlc_media_list_player_is_playing(p_mlp) = 1);
end;
end;
function TPasLibVlcMediaList.IsPause(): Boolean;
begin
Result := FALSE;
if not Assigned(FPlayer) then
exit;
if (p_mlp <> NIL) then
begin
Result := (libvlc_media_list_player_get_state(p_mlp) = libvlc_Paused);
end;
end;
function TPasLibVlcMediaList.GetState(): TPasLibVlcPlayerState;
begin
Result := plvPlayer_NothingSpecial;
if not Assigned(FPlayer) then
exit;
if (p_mlp = NIL) then
exit;
case libvlc_media_list_player_get_state(p_mlp) of
libvlc_NothingSpecial:
Result := plvPlayer_NothingSpecial;
libvlc_Opening:
Result := plvPlayer_Opening;
libvlc_Buffering:
Result := plvPlayer_Buffering;
libvlc_Playing:
Result := plvPlayer_Playing;
libvlc_Paused:
Result := plvPlayer_Paused;
libvlc_Stopped:
Result := plvPlayer_Stopped;
libvlc_Ended:
Result := plvPlayer_Ended;
libvlc_Error:
Result := plvPlayer_Error;
end;
end;
function TPasLibVlcMediaList.GetStateName(): string;
begin
if Assigned(FPlayer) then
begin
if (p_mlp <> NIL) then
begin
case GetState() of
plvPlayer_NothingSpecial:
Result := 'Nothing Special';
plvPlayer_Opening:
Result := 'Opening';
plvPlayer_Buffering:
Result := 'Buffering';
plvPlayer_Playing:
Result := 'Playing';
plvPlayer_Paused:
Result := 'Paused';
plvPlayer_Stopped:
Result := 'Stopped';
plvPlayer_Ended:
Result := 'Ended';
plvPlayer_Error:
Result := 'Error';