forked from videolan/libvlcsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediaPlayer.cs
1966 lines (1718 loc) · 93.8 KB
/
MediaPlayer.cs
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
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared.Structures;
namespace LibVLCSharp.Shared
{
public class MediaPlayer : Internal
{
struct Native
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_new")]
internal static extern IntPtr LibVLCMediaPlayerNew(IntPtr libvlc);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_release")]
internal static extern void LibVLCMediaPlayerRelease(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_new_from_media")]
internal static extern IntPtr LibVLCMediaPlayerNewFromMedia(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_media")]
internal static extern void LibVLCMediaPlayerSetMedia(IntPtr mediaPlayer, IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_media")]
internal static extern IntPtr LibVLCMediaPlayerGetMedia(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_event_manager")]
internal static extern IntPtr LibVLCMediaPlayerEventManager(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_is_playing")]
internal static extern int LibVLCMediaPlayerIsPlaying(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_play")]
internal static extern int LibVLCMediaPlayerPlay(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_pause")]
internal static extern void LibVLCMediaPlayerSetPause(IntPtr mediaPlayer, bool pause);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_pause")]
internal static extern void LibVLCMediaPlayerPause(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_stop")]
internal static extern void LibVLCMediaPlayerStop(IntPtr mediaPlayer);
#if COCOA
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_nsobject")]
internal static extern void LibVLCMediaPlayerSetNsobject(IntPtr mediaPlayer, IntPtr drawable);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_nsobject")]
internal static extern IntPtr LibVLCMediaPlayerGetNsobject(IntPtr mediaPlayer);
#endif
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_xwindow")]
internal static extern void LibVLCMediaPlayerSetXwindow(IntPtr mediaPlayer, uint drawable);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_xwindow")]
internal static extern uint LibVLCMediaPlayerGetXwindow(IntPtr mediaPlayer);
#if WINDOWS
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_hwnd")]
internal static extern void LibVLCMediaPlayerSetHwnd(IntPtr mediaPlayer, IntPtr drawable);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_hwnd")]
internal static extern IntPtr LibVLCMediaPlayerGetHwnd(IntPtr mediaPlayer);
#endif
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_length")]
internal static extern long LibVLCMediaPlayerGetLength(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_time")]
internal static extern long LibVLCMediaPlayerGetTime(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_time")]
internal static extern void LibVLCMediaPlayerSetTime(IntPtr mediaPlayer, long time);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_position")]
internal static extern float LibVLCMediaPlayerGetPosition(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_position")]
internal static extern void LibVLCMediaPlayerSetPosition(IntPtr mediaPlayer, float position);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_chapter")]
internal static extern void LibVLCMediaPlayerSetChapter(IntPtr mediaPlayer, int chapter);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_chapter")]
internal static extern int LibVLCMediaPlayerGetChapter(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_chapter_count")]
internal static extern int LibVLCMediaPlayerGetChapterCount(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_will_play")]
internal static extern int LibVLCMediaPlayerWillPlay(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_chapter_count_for_title")]
internal static extern int LibVLCMediaPlayerGetChapterCountForTitle(IntPtr mediaPlayer, int title);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_title")]
internal static extern void LibVLCMediaPlayerSetTitle(IntPtr mediaPlayer, int title);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_title")]
internal static extern int LibVLCMediaPlayerGetTitle(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_title_count")]
internal static extern int LibVLCMediaPlayerGetTitleCount(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_previous_chapter")]
internal static extern void LibVLCMediaPlayerPreviousChapter(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_next_chapter")]
internal static extern void LibVLCMediaPlayerNextChapter(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_rate")]
internal static extern float LibVLCMediaPlayerGetRate(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_rate")]
internal static extern int LibVLCMediaPlayerSetRate(IntPtr mediaPlayer, float rate);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_state")]
internal static extern VLCState LibVLCMediaPlayerGetState(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_fps")]
internal static extern float LibVLCMediaPlayerGetFps(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_has_vout")]
internal static extern uint LibVLCMediaPlayerHasVout(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_is_seekable")]
internal static extern int LibVLCMediaPlayerIsSeekable(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_can_pause")]
internal static extern int LibVLCMediaPlayerCanPause(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_program_scrambled")]
internal static extern int LibVLCMediaPlayerProgramScrambled(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_next_frame")]
internal static extern void LibVLCMediaPlayerNextFrame(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_navigate")]
internal static extern void LibVLCMediaPlayerNavigate(IntPtr mediaPlayer, uint navigate);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_video_title_display")]
internal static extern void LibVLCMediaPlayerSetVideoTitleDisplay(IntPtr mediaPlayer, Position position, uint timeout);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_toggle_fullscreen")]
internal static extern void LibVLCToggleFullscreen(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_fullscreen")]
internal static extern void LibVLCSetFullscreen(IntPtr mediaPlayer, int fullscreen);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_get_fullscreen")]
internal static extern int LibVLCGetFullscreen(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_toggle_teletext")]
internal static extern void LibVLCToggleTeletext(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_equalizer")]
internal static extern int LibVLCMediaPlayerSetEqualizer(IntPtr mediaPlayer, IntPtr equalizer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_callbacks")]
internal static extern void LibVLCAudioSetCallbacks(IntPtr mediaPlayer, LibVLCAudioPlayCb play, LibVLCAudioPauseCb pause,
LibVLCAudioResumeCb resume, LibVLCAudioFlushCb flush, LibVLCAudioDrainCb drain, IntPtr opaque);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_volume_callback")]
internal static extern void LibVLCAudioSetVolumeCallback(IntPtr mediaPlayer, LibVLCVolumeCb volumeCallback);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_format_callbacks")]
internal static extern void LibVLCAudioSetFormatCallbacks(IntPtr mediaPlayer, LibVLCAudioSetupCb setup, LibVLCAudioCleanupCb cleanup);
// TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_format")]
internal static extern void LibVLCAudioSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string format,
uint rate, uint channels);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_enum")]
internal static extern IntPtr LibVLCAudioOutputDeviceEnum(IntPtr mediaPlayer);
// TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_set")]
internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string module,
[MarshalAs(UnmanagedType.LPStr)] string deviceId);
// TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_set")]
internal static extern int LibVLCAudioOutputSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string name);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_toggle_mute")]
internal static extern void LibVLCAudioToggleMute(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_mute")]
internal static extern int LibVLCAudioGetMute(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_mute")]
internal static extern void LibVLCAudioSetMute(IntPtr mediaPlayer, int status);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_volume")]
internal static extern int LibVLCAudioGetVolume(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_volume")]
internal static extern int LibVLCAudioSetVolume(IntPtr mediaPlayer, int volume);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_track_count")]
internal static extern int LibVLCAudioGetTrackCount(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_track_description")]
internal static extern IntPtr LibVLCAudioGetTrackDescription(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_track")]
internal static extern int LibVLCAudioGetTrack(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_track")]
internal static extern int LibVLCAudioSetTrack(IntPtr mediaPlayer, int track);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_channel")]
internal static extern int LibVLCAudioGetChannel(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_channel")]
internal static extern int LibVLCAudioSetChannel(IntPtr mediaPlayer, int channel);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_get_delay")]
internal static extern long LibVLCAudioGetDelay(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_delay")]
internal static extern int LibVLCAudioSetDelay(IntPtr mediaPlayer, long delay);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_callbacks")]
internal static extern void LibVLCVideoSetCallbacks(IntPtr mediaPlayer, LibVLCVideoLockCb lockCallback,
LibVLCVideoUnlockCb unlock, LibVLCVideoDisplayCb display, IntPtr opaque);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_format")]
internal static extern void LibVLCVideoSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string chroma,
uint width, uint height, uint pitch);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_format_callbacks")]
internal static extern void LibVLCVideoSetFormatCallbacks(IntPtr mediaPlayer, LibVLCVideoFormatCb setup,
LibVLCVideoCleanupCb cleanup);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_key_input")]
internal static extern void LibVLCVideoSetKeyInput(IntPtr mediaPlayer, int enable);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_mouse_input")]
internal static extern void LibVLCVideoSetMouseInput(IntPtr mediaPlayer, int enable);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_size")]
internal static extern unsafe int LibVLCVideoGetSize(IntPtr mediaPlayer, uint num, uint* px, uint* py);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_cursor")]
internal static extern unsafe int LibVLCVideoGetCursor(IntPtr mediaPlayer, uint num, int* px, int* py);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_scale")]
internal static extern float LibVLCVideoGetScale(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_scale")]
internal static extern void LibVLCVideoSetScale(IntPtr mediaPlayer, float factor);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_aspect_ratio")]
internal static extern string LibVLCVideoGetAspectRatio(IntPtr mediaPlayer);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_aspect_ratio")]
internal static extern void LibVLCVideoSetAspectRatio(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string aspect);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_spu")]
internal static extern int LibVLCVideoGetSpu(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_spu_count")]
internal static extern int LibVLCVideoGetSpuCount(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_spu_description")]
internal static extern IntPtr LibVLCVideoGetSpuDescription(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_spu")]
internal static extern int LibVLCVideoSetSpu(IntPtr mediaPlayer, int spu);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_subtitle_file")]
internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer,
[MarshalAs(UnmanagedType.LPStr)] string subtitle);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_spu_delay")]
internal static extern long LibVLCVideoGetSpuDelay(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_spu_delay")]
internal static extern int LibVLCVideoSetSpuDelay(IntPtr mediaPlayer, long delay);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_title_description")]
internal static extern IntPtr LibVLCVideoGetTitleDescription(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_full_title_descriptions")]
internal static extern int LibVLCMediaPlayerGetFullTitleDescriptions(IntPtr mediaPlayer, IntPtr titles);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_chapter_description")]
internal static extern IntPtr LibVLCVideoGetChapterDescription(IntPtr mediaPlayer,
int title);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_title_descriptions_release")]
internal static extern void LibVLCTitleDescriptionsRelease(IntPtr titles, uint count);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_get_full_chapter_descriptions")]
internal static extern int LibVLCMediaPlayerGetFullChapterDescriptions(IntPtr mediaPlayer, int titleIndex, ref IntPtr chapters);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_chapter_descriptions_release")]
internal static extern void LibVLCChapterDescriptionsRelease(IntPtr chapters, uint count);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_crop_geometry")]
internal static extern string LibVLCVideoGetCropGeometry(IntPtr mediaPlayer);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_crop_geometry")]
internal static extern void LibVLCVideoSetCropGeometry(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string geometry);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_teletext")]
internal static extern int LibVLCVideoGetTeletext(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_teletext")]
internal static extern void LibVLCVideoSetTeletext(IntPtr mediaPlayer, int page);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_track_count")]
internal static extern int LibVLCVideoGetTrackCount(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_track_description")]
internal static extern IntPtr LibVLCVideoGetTrackDescription(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_track")]
internal static extern int LibVLCVideoGetTrack(IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_track")]
internal static extern int LibVLCVideoSetTrack(IntPtr mediaPlayer, int track);
// TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_take_snapshot")]
internal static extern int LibVLCVideoTakeSnapshot(IntPtr mediaPlayer, uint num,
[MarshalAs(UnmanagedType.LPStr)] string filepath, uint width, uint height);
// TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_deinterlace")]
internal static extern void LibVLCVideoSetDeinterlace(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string mode);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_marquee_int")]
internal static extern int LibVLCVideoGetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_marquee_string")]
internal static extern string LibVLCVideoGetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_marquee_int")]
internal static extern void LibVLCVideoSetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option, int marqueeValue);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_marquee_string")]
internal static extern void LibVLCVideoSetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option, [MarshalAs(UnmanagedType.LPStr)] string marqueeValue);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_logo_int")]
internal static extern int LibVLCVideoGetLogoInt(IntPtr mediaPlayer, VideoLogoOption option);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_int")]
internal static extern void LibVLCVideoSetLogoInt(IntPtr mediaPlayer, VideoLogoOption option, int value);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_string")]
internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option,
[MarshalAs(UnmanagedType.LPStr)] string logoOptionValue);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_int")]
internal static extern int LibVLCVideoGetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_adjust_int")]
internal static extern void LibVLCVideoSetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option, int value);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_float")]
internal static extern float LibVLCVideoGetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_adjust_float")]
internal static extern void LibVLCVideoSetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option, float value);
//TODO: UTF8
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_add_slave")]
internal static extern int LibVLCMediaPlayerAddSlave(IntPtr mediaPlayer, MediaSlaveType mediaSlaveType,
[MarshalAs(UnmanagedType.LPStr)] string uri, bool selectWhenloaded);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_update_viewpoint")]
internal static extern int LibVLCVideoUpdateViewpoint(IntPtr mediaPlayer, VideoViewpoint viewpoint, bool absolute);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_track_description_list_release")]
internal static extern void LibVLCTrackDescriptionListRelease(IntPtr trackDescription);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_list_release")]
internal static extern void LibVLCAudioOutputDeviceListRelease(IntPtr list);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_renderer")]
internal static extern int LibVLCMediaPlayerSetRenderer(IntPtr mediaplayer, IntPtr renderItem);
#if ANDROID
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_set_android_context")]
internal static extern void LibVLCMediaPlayerSetAndroidContext(IntPtr mediaPlayer, IntPtr aWindow);
#endif
}
public void SetVideoFormatCallbacks()
{
throw new NotImplementedException();
}
MediaPlayerEventManager _eventManager;
/// <summary>Create an empty Media Player object</summary>
/// <param name="libVLC">
/// <para>the libvlc instance in which the Media Player</para>
/// <para>should be created.</para>
/// </param>
/// <returns>a new media player object, or NULL on error.</returns>
public MediaPlayer(LibVLC libVLC)
: base(() => Native.LibVLCMediaPlayerNew(libVLC.NativeReference), Native.LibVLCMediaPlayerRelease)
{
}
/// <summary>Create a Media Player object from a Media</summary>
/// <param name="media">
/// <para>the media. Afterwards the p_md can be safely</para>
/// <para>destroyed.</para>
/// </param>
/// <returns>a new media player object, or NULL on error.</returns>
public MediaPlayer(Media media)
: base(() => Native.LibVLCMediaPlayerNewFromMedia(media.NativeReference), Native.LibVLCMediaPlayerRelease)
{
}
/// <summary>
/// Get the media used by the media_player.
/// Set the media that will be used by the media_player.
/// If any, previous md will be released.
/// </summary>
public Media Media
{
get
{
var mediaPtr = Native.LibVLCMediaPlayerGetMedia(NativeReference);
return mediaPtr == IntPtr.Zero ? null : new Media(mediaPtr);
}
set => Native.LibVLCMediaPlayerSetMedia(NativeReference, value.NativeReference);
}
/// <summary>
/// Get the Event Manager from which the media player send event.
/// </summary>
public MediaPlayerEventManager EventManager
{
get
{
if (_eventManager == null)
{
var eventManagerPtr = Native.LibVLCMediaPlayerEventManager(NativeReference);
_eventManager = new MediaPlayerEventManager(eventManagerPtr);
}
return _eventManager;
}
}
/// <summary>
/// return true if the media player is playing, false otherwise
/// </summary>
public bool IsPlaying => Native.LibVLCMediaPlayerIsPlaying(NativeReference) != 0;
/// <summary>
/// Start playback with Media that is set
/// If playback was already started, this method has no effect
/// </summary>
/// <returns>true if successful</returns>
public bool Play() => Native.LibVLCMediaPlayerPlay(NativeReference) == 0;
/// <summary>
/// Set media and start playback
/// </summary>
/// <param name="media"></param>
/// <returns>true if successful</returns>
public bool Play(Media media)
{
Media = media;
return Play();
}
/// <summary>
/// Pause or resume (no effect if there is no media).
/// version LibVLC 1.1.1 or later
/// </summary>
/// <param name="pause">play/resume if true, pause if false</param>
[ApiVersion(1, 1)]
public void SetPause(bool pause) => Native.LibVLCMediaPlayerSetPause(NativeReference, pause);
/// <summary>
/// Toggle pause (no effect if there is no media)
/// </summary>
public void Pause() => Native.LibVLCMediaPlayerPause(NativeReference);
/// <summary>
/// Stop the playback (no effect if there is no media)
/// warning:
/// This is synchronous, and will block until all VLC threads have been joined.
/// Calling this from a VLC callback is a bound to cause a deadlock.
/// </summary>
public void Stop() => Native.LibVLCMediaPlayerStop(NativeReference);
#if COCOA
/// <summary>
/// Get the NSView handler previously set
/// return the NSView handler or 0 if none where set
/// <para></para>
/// <para></para>
/// Set the NSView handler where the media player should render its video output.
/// Use the vout called "macosx".
/// <para></para>
/// The drawable is an NSObject that follow the
/// VLCOpenGLVideoViewEmbedding protocol: VLCOpenGLVideoViewEmbedding NSObject
/// Or it can be an NSView object.
/// If you want to use it along with Qt4 see the QMacCocoaViewContainer.
/// Then the following code should work: { NSView *video = [[NSView
/// alloc] init]; QMacCocoaViewContainer *container = new
/// QMacCocoaViewContainer(video, parent);
/// libvlc_media_player_set_nsobject(mp, video); [video release]; }
/// You can find a live example in VLCVideoView in VLCKit.framework.
/// </summary>
public IntPtr NsObject
{
get => Native.LibVLCMediaPlayerGetNsobject(NativeReference);
set => Native.LibVLCMediaPlayerSetNsobject(NativeReference, value);
}
#endif
/// <summary>
/// Set an X Window System drawable where the media player should render its video output.
/// The call takes effect when the playback starts. If it is already started, it might need to be stopped before changes apply.
/// If LibVLC was built without X11 output support, then this function has no effects.
/// By default, LibVLC will capture input events on the video rendering area.
/// Use libvlc_video_set_mouse_input() and libvlc_video_set_key_input() to disable that and deliver events to the parent window / to the application instead.
/// By design, the X11 protocol delivers input events to only one recipient.
/// <para></para>
/// Warning:
/// The application must call the XInitThreads() function from Xlib before libvlc_new(), and before any call to XOpenDisplay() directly
/// or via any other library.Failure to call XInitThreads() will seriously impede LibVLC performance.
/// Calling XOpenDisplay() before XInitThreads() will eventually crash the process. That is a limitation of Xlib.
/// uint: X11 window ID
/// </summary>
public uint XWindow
{
get => Native.LibVLCMediaPlayerGetXwindow(NativeReference);
set => Native.LibVLCMediaPlayerSetXwindow(NativeReference, value);
}
#if WINDOWS
/// <summary>
/// Set a Win32/Win64 API window handle (HWND) where the media player
/// should render its video output. If LibVLC was built without
/// Win32/Win64 API output support, then this has no effects.
/// <para></para>
/// Get the Windows API window handle (HWND) previously set
/// </summary>
public IntPtr Hwnd
{
get => Native.LibVLCMediaPlayerGetHwnd(NativeReference);
set => Native.LibVLCMediaPlayerSetHwnd(NativeReference, value);
}
#endif
/// <summary>
/// The movie length (in ms), or -1 if there is no media.
/// </summary>
public long Length => Native.LibVLCMediaPlayerGetLength(NativeReference);
/// <summary>
/// Set the movie time (in ms). This has no effect if no media is being
/// played. Not all formats and protocols support this.
/// <para></para>
/// Get the movie time (in ms), or -1 if there is no media.
/// </summary>
public long Time
{
get => Native.LibVLCMediaPlayerGetTime(NativeReference);
set => Native.LibVLCMediaPlayerSetTime(NativeReference, value);
}
/// <summary>
/// Set movie position as percentage between 0.0 and 1.0. This has no
/// effect if playback is not enabled. This might not work depending on
/// the underlying input format and protocol.
/// <para></para>
/// Get movie position as percentage between 0.0 and 1.0.
/// </summary>
public float Position
{
get => Native.LibVLCMediaPlayerGetPosition(NativeReference);
set => Native.LibVLCMediaPlayerSetPosition(NativeReference, value);
}
/// <summary>
/// Set movie chapter (if applicable).
/// <para></para>
/// Get the movie chapter number currently playing, or -1 if there is no media.
/// </summary>
public int Chapter
{
get => Native.LibVLCMediaPlayerGetChapter(NativeReference);
set => Native.LibVLCMediaPlayerSetChapter(NativeReference, value);
}
/// <summary>
/// Get the number of chapters in movie, or -1.
/// </summary>
public int ChapterCount => Native.LibVLCMediaPlayerGetChapterCount(NativeReference);
/// <summary>
/// True if the player is able to play
/// </summary>
public bool WillPlay => Native.LibVLCMediaPlayerWillPlay(NativeReference) != 0;
/// <summary>
/// Get the number of chapters in title, or -1
/// </summary>
/// <param name="title"></param>
/// <returns></returns>
public int ChapterCountForTitle(int title) => Native.LibVLCMediaPlayerGetChapterCountForTitle(NativeReference, title);
/// <summary>
/// Set movie title number to play
/// <para></para>
/// Get movie title number currently playing, or -1
/// </summary>
public int Title
{
get => Native.LibVLCMediaPlayerGetTitle(NativeReference);
set => Native.LibVLCMediaPlayerSetTitle(NativeReference, value);
}
/// <summary>
/// The title number count, or -1
/// </summary>
public int TitleCount => Native.LibVLCMediaPlayerGetTitleCount(NativeReference);
/// <summary>
/// Set previous chapter (if applicable)
/// </summary>
public void PreviousChapter()
{
Native.LibVLCMediaPlayerPreviousChapter(NativeReference);
}
/// <summary>
/// Set next chapter (if applicable)
/// </summary>
public void NextChapter()
{
Native.LibVLCMediaPlayerNextChapter(NativeReference);
}
/// <summary>
/// Get the requested movie play rate.
/// warning
/// <para></para>
/// Depending on the underlying media, the requested rate may be
/// different from the real playback rate.
/// </summary>
public float Rate => Native.LibVLCMediaPlayerGetRate(NativeReference);
/// <summary>
/// Set movie play rate
/// </summary>
/// <param name="rate">movie play rate to set</param>
/// <returns>
/// return -1 if an error was detected, 0 otherwise (but even then, it
/// might not actually work depending on the underlying media protocol)
/// </returns>
public int SetRate(float rate)
{
return Native.LibVLCMediaPlayerSetRate(NativeReference, rate);
}
/// <summary>
/// Get the current state of the media player (playing, paused, ...)
/// </summary>
public VLCState State => Native.LibVLCMediaPlayerGetState(NativeReference);
float _fps;
/// <summary>
/// Get the frames per second (fps) for this playing movie, or 0 if unspecified
/// </summary>
[ApiVersion(major: 3, minor: 0, min: false, strict: true)]
public float Fps
{
get { _fps = Native.LibVLCMediaPlayerGetFps(NativeReference); return _fps; }
}
/// <summary>
/// Get the number of video outputs
/// </summary>
public uint VoutCount => Native.LibVLCMediaPlayerHasVout(NativeReference);
/// <summary>
/// True if the media player can seek
/// </summary>
public bool IsSeekable => Native.LibVLCMediaPlayerIsSeekable(NativeReference) != 0;
/// <summary>
/// True if the media player can pause
/// </summary>
public bool CanPause => Native.LibVLCMediaPlayerCanPause(NativeReference) != 0;
/// <summary>
/// True if the current program is scrambled
/// <para></para>
/// LibVLC 2.2.0 or later
/// </summary>
public bool ProgramScambled => Native.LibVLCMediaPlayerProgramScrambled(NativeReference) != 0;
/// <summary>
/// Display the next frame (if supported)
/// </summary>
public void NextFrame()
{
Native.LibVLCMediaPlayerNextFrame(NativeReference);
}
/// <summary>
/// Navigate through DVD Menu
/// </summary>
/// <param name="navigate">the Navigation mode</param>
/// LibVLC 2.0.0 or later
public void Navigate(uint navigate)
{
Native.LibVLCMediaPlayerNavigate(NativeReference, navigate);
}
/// <summary>
/// Set if, and how, the video title will be shown when media is played.
/// </summary>
/// <param name="position">position at which to display the title, or libvlc_position_disable to prevent the title from being displayed</param>
/// <param name="timeout">title display timeout in milliseconds (ignored if libvlc_position_disable)</param>
/// LibVLC 2.1.0 or later
public void SetVideoTitleDisplay(Position position, uint timeout)
{
Native.LibVLCMediaPlayerSetVideoTitleDisplay(NativeReference, position, timeout);
}
/// <summary>
/// Toggle fullscreen status on non-embedded video outputs.
/// <para></para>
/// warning: The same limitations applies to this function as to MediaPlayer::setFullscreen()
/// </summary>
public void ToggleFullscreen()
{
Native.LibVLCToggleFullscreen(NativeReference);
}
/// <summary>
/// Enable or disable fullscreen.
/// Warning
/// With most window managers, only a top-level windows can be in full-screen mode.
/// Hence, this function will not operate properly if libvlc_media_player_set_xwindow() was used to embed the video in a non-top-level window.
/// In that case, the embedding window must be reparented to the root window before fullscreen mode is enabled.
/// You will want to reparent it back to its normal parent when disabling fullscreen.
/// <para></para>
/// return the fullscreen status (boolean)
/// </summary>
public bool Fullscreen
{
get => Native.LibVLCGetFullscreen(NativeReference) != 0;
set => Native.LibVLCSetFullscreen(NativeReference, value ? 1 : 0);
}