MediaPlayer.cs 98.3 KB
Newer Older
Martin Finkel's avatar
Martin Finkel committed
1 2 3 4
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
5
using LibVLCSharp.Shared.Structures;
Martin Finkel's avatar
Martin Finkel committed
6

7
namespace LibVLCSharp.Shared
Martin Finkel's avatar
Martin Finkel committed
8 9 10 11 12
{
    public class MediaPlayer : Internal
    {
        struct Native
        {
13

14
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
15
                EntryPoint = "libvlc_media_player_new")]
Martin Finkel's avatar
Martin Finkel committed
16
            internal static extern IntPtr LibVLCMediaPlayerNew(IntPtr libvlc);
Martin Finkel's avatar
Martin Finkel committed
17

18

19
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
20 21 22
                EntryPoint = "libvlc_media_player_release")]
            internal static extern void LibVLCMediaPlayerRelease(IntPtr mediaPlayer);

23

24
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
25 26 27
                EntryPoint = "libvlc_media_player_new_from_media")]
            internal static extern IntPtr LibVLCMediaPlayerNewFromMedia(IntPtr media);

28

29
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
30 31 32
                EntryPoint = "libvlc_media_player_set_media")]
            internal static extern void LibVLCMediaPlayerSetMedia(IntPtr mediaPlayer, IntPtr media);

33

34
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
35 36 37
                EntryPoint = "libvlc_media_player_get_media")]
            internal static extern IntPtr LibVLCMediaPlayerGetMedia(IntPtr mediaPlayer);

38

39
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
40 41
                EntryPoint = "libvlc_media_player_event_manager")]
            internal static extern IntPtr LibVLCMediaPlayerEventManager(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
42

43

44
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
45 46 47
                EntryPoint = "libvlc_media_player_is_playing")]
            internal static extern int LibVLCMediaPlayerIsPlaying(IntPtr mediaPlayer);

48

49
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
50 51 52
                EntryPoint = "libvlc_media_player_play")]
            internal static extern int LibVLCMediaPlayerPlay(IntPtr mediaPlayer);

53

54
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
55 56 57
                EntryPoint = "libvlc_media_player_set_pause")]
            internal static extern void LibVLCMediaPlayerSetPause(IntPtr mediaPlayer, bool pause);

58

59
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
60 61 62
                EntryPoint = "libvlc_media_player_pause")]
            internal static extern void LibVLCMediaPlayerPause(IntPtr mediaPlayer);

63

64
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
65 66
                EntryPoint = "libvlc_media_player_stop")]
            internal static extern void LibVLCMediaPlayerStop(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
67
#if COCOA
68
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
69 70 71
                EntryPoint = "libvlc_media_player_set_nsobject")]
            internal static extern void LibVLCMediaPlayerSetNsobject(IntPtr mediaPlayer, IntPtr drawable);

72
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
73 74
                EntryPoint = "libvlc_media_player_get_nsobject")]
            internal static extern IntPtr LibVLCMediaPlayerGetNsobject(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
75
#endif
76

77
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
78 79 80
                EntryPoint = "libvlc_media_player_set_xwindow")]
            internal static extern void LibVLCMediaPlayerSetXwindow(IntPtr mediaPlayer, uint drawable);

81
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
82 83
                EntryPoint = "libvlc_media_player_get_xwindow")]
            internal static extern uint LibVLCMediaPlayerGetXwindow(IntPtr mediaPlayer);
84

85
#if MODERN_DESKTOP || NET40
86
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
87 88 89
                EntryPoint = "libvlc_media_player_set_hwnd")]
            internal static extern void LibVLCMediaPlayerSetHwnd(IntPtr mediaPlayer, IntPtr drawable);

90
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
91 92
                EntryPoint = "libvlc_media_player_get_hwnd")]
            internal static extern IntPtr LibVLCMediaPlayerGetHwnd(IntPtr mediaPlayer);
93
#endif
94

95
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
96 97 98
                EntryPoint = "libvlc_media_player_get_length")]
            internal static extern long LibVLCMediaPlayerGetLength(IntPtr mediaPlayer);

99

100
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
101 102 103
                EntryPoint = "libvlc_media_player_get_time")]
            internal static extern long LibVLCMediaPlayerGetTime(IntPtr mediaPlayer);

104

105
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
106 107 108
                EntryPoint = "libvlc_media_player_set_time")]
            internal static extern void LibVLCMediaPlayerSetTime(IntPtr mediaPlayer, long time);

109

110
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
111 112 113
                EntryPoint = "libvlc_media_player_get_position")]
            internal static extern float LibVLCMediaPlayerGetPosition(IntPtr mediaPlayer);

114

115
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
116 117 118
                EntryPoint = "libvlc_media_player_set_position")]
            internal static extern void LibVLCMediaPlayerSetPosition(IntPtr mediaPlayer, float position);

119

120
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
121 122 123
                EntryPoint = "libvlc_media_player_set_chapter")]
            internal static extern void LibVLCMediaPlayerSetChapter(IntPtr mediaPlayer, int chapter);

124

125
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
126 127 128
                EntryPoint = "libvlc_media_player_get_chapter")]
            internal static extern int LibVLCMediaPlayerGetChapter(IntPtr mediaPlayer);

129

130
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
131 132
                EntryPoint = "libvlc_media_player_get_chapter_count")]
            internal static extern int LibVLCMediaPlayerGetChapterCount(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
133

134

135
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
136 137 138
                EntryPoint = "libvlc_media_player_will_play")]
            internal static extern int LibVLCMediaPlayerWillPlay(IntPtr mediaPlayer);

139

140
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
141 142 143
                EntryPoint = "libvlc_media_player_get_chapter_count_for_title")]
            internal static extern int LibVLCMediaPlayerGetChapterCountForTitle(IntPtr mediaPlayer, int title);

144

145
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
146 147 148
                EntryPoint = "libvlc_media_player_set_title")]
            internal static extern void LibVLCMediaPlayerSetTitle(IntPtr mediaPlayer, int title);

149

150
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
151 152 153
                EntryPoint = "libvlc_media_player_get_title")]
            internal static extern int LibVLCMediaPlayerGetTitle(IntPtr mediaPlayer);

154

155
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
156 157 158
                EntryPoint = "libvlc_media_player_get_title_count")]
            internal static extern int LibVLCMediaPlayerGetTitleCount(IntPtr mediaPlayer);

159

160
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
161 162 163
                EntryPoint = "libvlc_media_player_previous_chapter")]
            internal static extern void LibVLCMediaPlayerPreviousChapter(IntPtr mediaPlayer);

164

165
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
166 167 168
                EntryPoint = "libvlc_media_player_next_chapter")]
            internal static extern void LibVLCMediaPlayerNextChapter(IntPtr mediaPlayer);

169

170
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
171 172 173
                EntryPoint = "libvlc_media_player_get_rate")]
            internal static extern float LibVLCMediaPlayerGetRate(IntPtr mediaPlayer);

174

175
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
176 177 178
                EntryPoint = "libvlc_media_player_set_rate")]
            internal static extern int LibVLCMediaPlayerSetRate(IntPtr mediaPlayer, float rate);

179

180
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
181 182 183
                EntryPoint = "libvlc_media_player_get_state")]
            internal static extern VLCState LibVLCMediaPlayerGetState(IntPtr mediaPlayer);

184

185
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
186 187 188
                EntryPoint = "libvlc_media_player_get_fps")]
            internal static extern float LibVLCMediaPlayerGetFps(IntPtr mediaPlayer);

189

190
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
191 192 193
                EntryPoint = "libvlc_media_player_has_vout")]
            internal static extern uint LibVLCMediaPlayerHasVout(IntPtr mediaPlayer);

194

195
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
196 197 198
                EntryPoint = "libvlc_media_player_is_seekable")]
            internal static extern int LibVLCMediaPlayerIsSeekable(IntPtr mediaPlayer);

199

200
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
201 202 203
                EntryPoint = "libvlc_media_player_can_pause")]
            internal static extern int LibVLCMediaPlayerCanPause(IntPtr mediaPlayer);

204

205
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
206 207 208
                EntryPoint = "libvlc_media_player_program_scrambled")]
            internal static extern int LibVLCMediaPlayerProgramScrambled(IntPtr mediaPlayer);

209

210
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
211 212 213
                EntryPoint = "libvlc_media_player_next_frame")]
            internal static extern void LibVLCMediaPlayerNextFrame(IntPtr mediaPlayer);

214

215
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
216 217 218
                EntryPoint = "libvlc_media_player_navigate")]
            internal static extern void LibVLCMediaPlayerNavigate(IntPtr mediaPlayer, uint navigate);

219

220
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
221 222 223
                EntryPoint = "libvlc_media_player_set_video_title_display")]
            internal static extern void LibVLCMediaPlayerSetVideoTitleDisplay(IntPtr mediaPlayer, Position position, uint timeout);

224

225
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
226 227
                EntryPoint = "libvlc_toggle_fullscreen")]
            internal static extern void LibVLCToggleFullscreen(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
228

229

230
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
231 232 233
                EntryPoint = "libvlc_set_fullscreen")]
            internal static extern void LibVLCSetFullscreen(IntPtr mediaPlayer, int fullscreen);

234

235
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
236 237 238
                EntryPoint = "libvlc_get_fullscreen")]
            internal static extern int LibVLCGetFullscreen(IntPtr mediaPlayer);

239

240
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
241 242 243
                EntryPoint = "libvlc_toggle_teletext")]
            internal static extern void LibVLCToggleTeletext(IntPtr mediaPlayer);

244

245
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
246 247 248
                EntryPoint = "libvlc_media_player_set_equalizer")]
            internal static extern int LibVLCMediaPlayerSetEqualizer(IntPtr mediaPlayer, IntPtr equalizer);

249

250
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
251
                EntryPoint = "libvlc_audio_set_callbacks")]
Martin Finkel's avatar
Martin Finkel committed
252
            internal static extern void LibVLCAudioSetCallbacks(IntPtr mediaPlayer, LibVLCAudioPlayCb play, LibVLCAudioPauseCb pause,
Martin Finkel's avatar
Martin Finkel committed
253 254
                LibVLCAudioResumeCb resume, LibVLCAudioFlushCb flush, LibVLCAudioDrainCb drain, IntPtr opaque);

255

256
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
257 258 259
                EntryPoint = "libvlc_audio_set_volume_callback")]
            internal static extern void LibVLCAudioSetVolumeCallback(IntPtr mediaPlayer, LibVLCVolumeCb volumeCallback);

260

261
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
262 263 264 265
                EntryPoint = "libvlc_audio_set_format_callbacks")]
            internal static extern void LibVLCAudioSetFormatCallbacks(IntPtr mediaPlayer, LibVLCAudioSetupCb setup, LibVLCAudioCleanupCb cleanup);

            // TODO: UTF8
266

267
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
268 269
                EntryPoint = "libvlc_audio_set_format")]
            internal static extern void LibVLCAudioSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string format,
Martin Finkel's avatar
Martin Finkel committed
270 271
                uint rate, uint channels);

272

273
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
274 275 276 277
                EntryPoint = "libvlc_audio_output_device_enum")]
            internal static extern IntPtr LibVLCAudioOutputDeviceEnum(IntPtr mediaPlayer);

            // TODO: UTF8
278

279
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
280
                EntryPoint = "libvlc_audio_output_device_set")]
Martin Finkel's avatar
Martin Finkel committed
281
            internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string module,
Martin Finkel's avatar
Martin Finkel committed
282 283 284
                [MarshalAs(UnmanagedType.LPStr)] string deviceId);

            // TODO: UTF8
285

286
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
287 288 289
                EntryPoint = "libvlc_audio_output_set")]
            internal static extern int LibVLCAudioOutputSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string name);

290

291
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
292 293 294
                EntryPoint = "libvlc_audio_toggle_mute")]
            internal static extern void LibVLCAudioToggleMute(IntPtr mediaPlayer);

295

296
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
297 298 299
                EntryPoint = "libvlc_audio_get_mute")]
            internal static extern int LibVLCAudioGetMute(IntPtr mediaPlayer);

300

301
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
302 303 304
                EntryPoint = "libvlc_audio_set_mute")]
            internal static extern void LibVLCAudioSetMute(IntPtr mediaPlayer, int status);

305

306
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
307 308 309
                EntryPoint = "libvlc_audio_get_volume")]
            internal static extern int LibVLCAudioGetVolume(IntPtr mediaPlayer);

310

311
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
312 313 314
                EntryPoint = "libvlc_audio_set_volume")]
            internal static extern int LibVLCAudioSetVolume(IntPtr mediaPlayer, int volume);

315

316
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
317 318 319
                EntryPoint = "libvlc_audio_get_track_count")]
            internal static extern int LibVLCAudioGetTrackCount(IntPtr mediaPlayer);

320

321
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
322 323 324
                EntryPoint = "libvlc_audio_get_track_description")]
            internal static extern IntPtr LibVLCAudioGetTrackDescription(IntPtr mediaPlayer);

325

326
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
327 328 329
                EntryPoint = "libvlc_audio_get_track")]
            internal static extern int LibVLCAudioGetTrack(IntPtr mediaPlayer);

330

331
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
332 333 334
                EntryPoint = "libvlc_audio_set_track")]
            internal static extern int LibVLCAudioSetTrack(IntPtr mediaPlayer, int track);

335

336
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
337 338 339
                EntryPoint = "libvlc_audio_get_channel")]
            internal static extern int LibVLCAudioGetChannel(IntPtr mediaPlayer);

340

341
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
342 343 344
                EntryPoint = "libvlc_audio_set_channel")]
            internal static extern int LibVLCAudioSetChannel(IntPtr mediaPlayer, int channel);

345

346
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
347 348 349
                EntryPoint = "libvlc_audio_get_delay")]
            internal static extern long LibVLCAudioGetDelay(IntPtr mediaPlayer);

350

351
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
352 353 354
                EntryPoint = "libvlc_audio_set_delay")]
            internal static extern int LibVLCAudioSetDelay(IntPtr mediaPlayer, long delay);

355

356
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
357
                EntryPoint = "libvlc_video_set_callbacks")]
Martin Finkel's avatar
Martin Finkel committed
358
            internal static extern void LibVLCVideoSetCallbacks(IntPtr mediaPlayer, LibVLCVideoLockCb lockCallback,
Martin Finkel's avatar
Martin Finkel committed
359 360 361
                LibVLCVideoUnlockCb unlock, LibVLCVideoDisplayCb display, IntPtr opaque);

            //TODO: UTF8
362

363
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
364
                EntryPoint = "libvlc_video_set_format")]
Martin Finkel's avatar
Martin Finkel committed
365
            internal static extern void LibVLCVideoSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string chroma,
Martin Finkel's avatar
Martin Finkel committed
366 367
                uint width, uint height, uint pitch);

368

369
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
370
                EntryPoint = "libvlc_video_set_format_callbacks")]
Martin Finkel's avatar
Martin Finkel committed
371
            internal static extern void LibVLCVideoSetFormatCallbacks(IntPtr mediaPlayer, LibVLCVideoFormatCb setup,
372
                LibVLCVideoCleanupCb cleanup);
Martin Finkel's avatar
Martin Finkel committed
373

374

375
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
376 377 378
                EntryPoint = "libvlc_video_set_key_input")]
            internal static extern void LibVLCVideoSetKeyInput(IntPtr mediaPlayer, int enable);

379

380
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
381 382 383
                EntryPoint = "libvlc_video_set_mouse_input")]
            internal static extern void LibVLCVideoSetMouseInput(IntPtr mediaPlayer, int enable);

384

385
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
386
                EntryPoint = "libvlc_video_get_size")]
387
            internal static extern int LibVLCVideoGetSize(IntPtr mediaPlayer, uint num, ref uint px, ref uint py);
Martin Finkel's avatar
Martin Finkel committed
388

389

390
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
391
                EntryPoint = "libvlc_video_get_cursor")]
392
            internal static extern int LibVLCVideoGetCursor(IntPtr mediaPlayer, uint num, ref int px, ref int py);
Martin Finkel's avatar
Martin Finkel committed
393

394

395
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
396 397 398
                EntryPoint = "libvlc_video_get_scale")]
            internal static extern float LibVLCVideoGetScale(IntPtr mediaPlayer);

399

400
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
401 402 403
                EntryPoint = "libvlc_video_set_scale")]
            internal static extern void LibVLCVideoSetScale(IntPtr mediaPlayer, float factor);

404

405
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
406
                EntryPoint = "libvlc_video_get_aspect_ratio")]
407
            internal static extern string LibVLCVideoGetAspectRatio(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
408 409

            //TODO: UTF8
410

411
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
412 413
                EntryPoint = "libvlc_video_set_aspect_ratio")]
            internal static extern void LibVLCVideoSetAspectRatio(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string aspect);
Martin Finkel's avatar
Martin Finkel committed
414

415

416
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
417 418 419
                EntryPoint = "libvlc_video_get_spu")]
            internal static extern int LibVLCVideoGetSpu(IntPtr mediaPlayer);

420

421
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
422 423 424
                EntryPoint = "libvlc_video_get_spu_count")]
            internal static extern int LibVLCVideoGetSpuCount(IntPtr mediaPlayer);

425

426
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
427 428 429
                EntryPoint = "libvlc_video_get_spu_description")]
            internal static extern IntPtr LibVLCVideoGetSpuDescription(IntPtr mediaPlayer);

430

431
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
432 433 434 435
                EntryPoint = "libvlc_video_set_spu")]
            internal static extern int LibVLCVideoSetSpu(IntPtr mediaPlayer, int spu);

            //TODO: UTF8
436

437
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
438 439 440 441
                EntryPoint = "libvlc_video_set_subtitle_file")]
            internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer,
                [MarshalAs(UnmanagedType.LPStr)] string subtitle);

442

443
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
444 445 446
                EntryPoint = "libvlc_video_get_spu_delay")]
            internal static extern long LibVLCVideoGetSpuDelay(IntPtr mediaPlayer);

447

448
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
449 450 451
                EntryPoint = "libvlc_video_set_spu_delay")]
            internal static extern int LibVLCVideoSetSpuDelay(IntPtr mediaPlayer, long delay);

452

453
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
454 455 456
                EntryPoint = "libvlc_video_get_title_description")]
            internal static extern IntPtr LibVLCVideoGetTitleDescription(IntPtr mediaPlayer);

457

458
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
459 460
                EntryPoint = "libvlc_media_player_get_full_title_descriptions")]
            internal static extern int LibVLCMediaPlayerGetFullTitleDescriptions(IntPtr mediaPlayer, IntPtr titles);
Martin Finkel's avatar
Martin Finkel committed
461

462

463
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
464 465 466 467
                EntryPoint = "libvlc_video_get_chapter_description")]
            internal static extern IntPtr LibVLCVideoGetChapterDescription(IntPtr mediaPlayer,
                int title);

468

469
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
470 471 472
                EntryPoint = "libvlc_title_descriptions_release")]
            internal static extern void LibVLCTitleDescriptionsRelease(IntPtr titles, uint count);

473

474
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
475 476 477
                EntryPoint = "libvlc_media_player_get_full_chapter_descriptions")]
            internal static extern int LibVLCMediaPlayerGetFullChapterDescriptions(IntPtr mediaPlayer, int titleIndex, ref IntPtr chapters);

478

479
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
480 481
                EntryPoint = "libvlc_chapter_descriptions_release")]
            internal static extern void LibVLCChapterDescriptionsRelease(IntPtr chapters, uint count);
Martin Finkel's avatar
Martin Finkel committed
482

483

484
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
485
                EntryPoint = "libvlc_video_get_crop_geometry")]
486
            internal static extern string LibVLCVideoGetCropGeometry(IntPtr mediaPlayer);
Martin Finkel's avatar
Martin Finkel committed
487 488

            //TODO: UTF8
489

490
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
491 492
                EntryPoint = "libvlc_video_set_crop_geometry")]
            internal static extern void LibVLCVideoSetCropGeometry(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string geometry);
Martin Finkel's avatar
Martin Finkel committed
493

494

495
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
496 497 498
                EntryPoint = "libvlc_video_get_teletext")]
            internal static extern int LibVLCVideoGetTeletext(IntPtr mediaPlayer);

499

500
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
501 502 503
                EntryPoint = "libvlc_video_set_teletext")]
            internal static extern void LibVLCVideoSetTeletext(IntPtr mediaPlayer, int page);

504

505
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
506 507 508
                EntryPoint = "libvlc_video_get_track_count")]
            internal static extern int LibVLCVideoGetTrackCount(IntPtr mediaPlayer);

509

510
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
511 512 513
                EntryPoint = "libvlc_video_get_track_description")]
            internal static extern IntPtr LibVLCVideoGetTrackDescription(IntPtr mediaPlayer);

514

515
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
516 517 518
                EntryPoint = "libvlc_video_get_track")]
            internal static extern int LibVLCVideoGetTrack(IntPtr mediaPlayer);

519

520
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
521 522
                EntryPoint = "libvlc_video_set_track")]
            internal static extern int LibVLCVideoSetTrack(IntPtr mediaPlayer, int track);
Martin Finkel's avatar
Martin Finkel committed
523

Martin Finkel's avatar
Martin Finkel committed
524
            // TODO: UTF8
525

526
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
527
                EntryPoint = "libvlc_video_take_snapshot")]
Martin Finkel's avatar
Martin Finkel committed
528
            internal static extern int LibVLCVideoTakeSnapshot(IntPtr mediaPlayer, uint num,
Martin Finkel's avatar
Martin Finkel committed
529 530 531
                [MarshalAs(UnmanagedType.LPStr)] string filepath, uint width, uint height);

            // TODO: UTF8
532

533
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
534 535 536
                EntryPoint = "libvlc_video_set_deinterlace")]
            internal static extern void LibVLCVideoSetDeinterlace(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string mode);

537

538
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
539
                EntryPoint = "libvlc_video_get_marquee_int")]
540
            internal static extern int LibVLCVideoGetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option);
Martin Finkel's avatar
Martin Finkel committed
541

542

543
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
544
                EntryPoint = "libvlc_video_get_marquee_string")]
545
            internal static extern string LibVLCVideoGetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option);
Martin Finkel's avatar
Martin Finkel committed
546

547

548
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
549
                EntryPoint = "libvlc_video_set_marquee_int")]
550
            internal static extern void LibVLCVideoSetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option, int marqueeValue);
Martin Finkel's avatar
Martin Finkel committed
551 552

            //TODO: UTF8
553

554
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
555
                EntryPoint = "libvlc_video_set_marquee_string")]
556
            internal static extern void LibVLCVideoSetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option, [MarshalAs(UnmanagedType.LPStr)] string marqueeValue);
Martin Finkel's avatar
Martin Finkel committed
557

558

559
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
560
                EntryPoint = "libvlc_video_get_logo_int")]
561
            internal static extern int LibVLCVideoGetLogoInt(IntPtr mediaPlayer, VideoLogoOption option);
Martin Finkel's avatar
Martin Finkel committed
562

563

564
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
565
                EntryPoint = "libvlc_video_set_logo_int")]
566
            internal static extern void LibVLCVideoSetLogoInt(IntPtr mediaPlayer, VideoLogoOption option, int value);
Martin Finkel's avatar
Martin Finkel committed
567 568

            //TODO: UTF8
569

570
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
571
                EntryPoint = "libvlc_video_set_logo_string")]
Martin Finkel's avatar
Martin Finkel committed
572
            internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option,
573
                [MarshalAs(UnmanagedType.LPStr)] string logoOptionValue);
Martin Finkel's avatar
Martin Finkel committed
574

575

576
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
577
                EntryPoint = "libvlc_video_get_adjust_int")]
578
            internal static extern int LibVLCVideoGetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option);
Martin Finkel's avatar
Martin Finkel committed
579

580

581
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
582
                EntryPoint = "libvlc_video_set_adjust_int")]
583
            internal static extern void LibVLCVideoSetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option, int value);
Martin Finkel's avatar
Martin Finkel committed
584

585

586
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
587
                EntryPoint = "libvlc_video_get_adjust_float")]
588
            internal static extern float LibVLCVideoGetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option);
Martin Finkel's avatar
Martin Finkel committed
589

590

591
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
592
                EntryPoint = "libvlc_video_set_adjust_float")]
593
            internal static extern void LibVLCVideoSetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option, float value);
Martin Finkel's avatar
Martin Finkel committed
594

Martin Finkel's avatar
Martin Finkel committed
595
            //TODO: UTF8
596

597
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
598
                EntryPoint = "libvlc_media_player_add_slave")]
Martin Finkel's avatar
Martin Finkel committed
599
            internal static extern int LibVLCMediaPlayerAddSlave(IntPtr mediaPlayer, MediaSlaveType mediaSlaveType,
Martin Finkel's avatar
Martin Finkel committed
600 601
                [MarshalAs(UnmanagedType.LPStr)] string uri, bool selectWhenloaded);

602

603
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
604 605
                EntryPoint = "libvlc_video_update_viewpoint")]
            internal static extern int LibVLCVideoUpdateViewpoint(IntPtr mediaPlayer, VideoViewpoint viewpoint, bool absolute);
Martin Finkel's avatar
Martin Finkel committed
606

607

608
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
Martin Finkel's avatar
Martin Finkel committed
609 610
                EntryPoint = "libvlc_track_description_list_release")]
            internal static extern void LibVLCTrackDescriptionListRelease(IntPtr trackDescription);
611

612

613
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
614 615
                EntryPoint = "libvlc_audio_output_device_list_release")]
            internal static extern void LibVLCAudioOutputDeviceListRelease(IntPtr list);
616

617

618
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
619 620
                EntryPoint = "libvlc_media_player_set_renderer")]
            internal static extern int LibVLCMediaPlayerSetRenderer(IntPtr mediaplayer, IntPtr renderItem);
621 622

#if ANDROID
623

624
            [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
625 626
                EntryPoint = "libvlc_media_player_set_android_context")]
            internal static extern void LibVLCMediaPlayerSetAndroidContext(IntPtr mediaPlayer, IntPtr aWindow);
627
#endif
Martin Finkel's avatar
Martin Finkel committed
628 629 630 631 632 633 634 635

#if UNITY_ANDROID
            [DllImport(Constants.UnityPlugin)]
            internal static extern IntPtr CreateAndInitMediaPlayer(IntPtr libvlc);

            [DllImport(Constants.UnityPlugin, EntryPoint = "getVideoFrameVLC")]
            internal static extern IntPtr GetFrame(IntPtr mediaPlayer, out bool updated);
#endif
Martin Finkel's avatar
Martin Finkel committed
636
        }
Martin Finkel's avatar
Martin Finkel committed
637

Martin Finkel's avatar
Martin Finkel committed
638 639 640
        MediaPlayerEventManager _eventManager;

        /// <summary>Create an empty Media Player object</summary>
Martin Finkel's avatar
Martin Finkel committed
641
        /// <param name="libVLC">
Martin Finkel's avatar
Martin Finkel committed
642 643 644 645
        /// <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>
Martin Finkel's avatar
Martin Finkel committed
646
        public MediaPlayer(LibVLC libVLC)
Martin Finkel's avatar
Martin Finkel committed
647 648 649 650 651 652 653 654 655 656
            : base(() =>
#if UNITY_ANDROID
            /// This is a helper method to ease creating and configuring a MediaPlayer on Unity.Android.
            /// By just passing it a LibVLC object, it handles JNI_OnLoad, AWindow creation for off screen HW and setting the 
            /// Android Context. The C# JNI bindings from Xamarin.Android (Java.Interop) differ from the Unity.Android way.
            Native.CreateAndInitMediaPlayer(libVLC.NativeReference),
#else
            Native.LibVLCMediaPlayerNew(libVLC.NativeReference),
#endif
            Native.LibVLCMediaPlayerRelease)
Martin Finkel's avatar
Martin Finkel committed
657 658 659
        {
        }

Martin Finkel's avatar
Martin Finkel committed
660
#if !UNITY_ANDROID
Martin Finkel's avatar
Martin Finkel committed
661 662 663 664 665 666 667 668 669 670
        /// <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)
        {
        }
Martin Finkel's avatar
Martin Finkel committed
671
#endif
Martin Finkel's avatar
Martin Finkel committed
672
        /// <summary>
Martin Finkel's avatar
Martin Finkel committed
673
        /// Get the media used by the media_player.
Martin Finkel's avatar
Martin Finkel committed
674