private void OnDisplayQuestion(IntPtr userdata, IntPtr dialogid, IntPtr title, IntPtr text, DialogQuestionType questiontype, IntPtr cancel, IntPtr action1, IntPtr action2) { string strTitle = Utf8InteropStringConverter.Utf8InteropToString(title); string strText = Utf8InteropStringConverter.Utf8InteropToString(text); string strCancelButton = Utf8InteropStringConverter.Utf8InteropToString(cancel); string strAction1Button = Utf8InteropStringConverter.Utf8InteropToString(action1); string strAction2Button = Utf8InteropStringConverter.Utf8InteropToString(action2); var cts = new CancellationTokenSource(); this.openDialogsCancellationTokens.Add(dialogid, cts); Task.Run(() => this.currentDialogManager.DisplayQuestionAsync(userdata, dialogid, strTitle, strText, questiontype, strCancelButton, strAction1Button, strAction2Button, cts.Token)) .ContinueWith((Action <Task <QuestionAction?> >)(task => { if (task.IsCompleted && task.Result != null) { this.myManager.PostAction(dialogid, (int)task.Result.Value); } else if (!task.IsCanceled) { this.myManager.DismissDialog(dialogid); } this.openDialogsCancellationTokens.Remove(dialogid); })); }
private void OnLogInternal(IntPtr data, VlcLogLevel level, IntPtr ctx, string format, IntPtr args) { if (this._log != null) { // Original source for va_list handling: https://stackoverflow.com/a/37629480/2663813 var byteLength = Win32Interops._vscprintf(format, args) + 1; var utf8Buffer = Marshal.AllocHGlobal(byteLength); string formattedDecodedMessage; try { Win32Interops.vsprintf(utf8Buffer, format, args); formattedDecodedMessage = Utf8InteropStringConverter.Utf8InteropToString(utf8Buffer); } finally { Marshal.FreeHGlobal(utf8Buffer); } string module; string file; uint? line; this.Manager.GetLogContext(ctx, out module, out file, out line); // Do the notification on another thread, so that VLC is not interrupted by the logging #if NETSTANDARD1_3 Task.Run(() => this._log(this.myMediaPlayerInstance, new VlcMediaPlayerLogEventArgs(level, formattedDecodedMessage, module, file, line))); #else ThreadPool.QueueUserWorkItem(eventArgs => { this._log(this.myMediaPlayerInstance, (VlcMediaPlayerLogEventArgs)eventArgs); }, new VlcMediaPlayerLogEventArgs(level, formattedDecodedMessage, module, file, line)); #endif } }
private void OnDisplayError(IntPtr userdata, IntPtr title, IntPtr text) { string strTitle = Utf8InteropStringConverter.Utf8InteropToString(title); string strText = Utf8InteropStringConverter.Utf8InteropToString(text); Task.Run(() => this.currentDialogManager?.DisplayErrorAsync(userdata, strTitle, strText)); }
private void OnDisplayLogin(IntPtr userdata, IntPtr dialogid, IntPtr title, IntPtr text, IntPtr defaultusername, bool askstore) { string strTitle = Utf8InteropStringConverter.Utf8InteropToString(title); string strText = Utf8InteropStringConverter.Utf8InteropToString(text); string strUsername = Utf8InteropStringConverter.Utf8InteropToString(defaultusername); var cts = new CancellationTokenSource(); this.openDialogsCancellationTokens.Add(dialogid, cts); Task.Run(() => this.currentDialogManager.DisplayLoginAsync(userdata, dialogid, strTitle, strText, strUsername, askstore, cts.Token)) .ContinueWith(task => { if (task.IsCompleted && task.Result != null) { using (var usr = Utf8InteropStringConverter.ToUtf8StringHandle(task.Result.Username)) using (var pass = Utf8InteropStringConverter.ToUtf8StringHandle(task.Result.Password)) { this.myManager.PostLogin(dialogid, usr, pass, task.Result.StoreCredentials); } } else if (!task.IsCanceled) { this.myManager.DismissDialog(dialogid); } this.openDialogsCancellationTokens.Remove(dialogid); }); }
private void OnMediaPlayerSnapshotTakenInternal(IntPtr ptr) { var args = MarshalHelper.PtrToStructure <VlcEventArg>(ptr); var fileName = Utf8InteropStringConverter.Utf8InteropToString(args.eventArgsUnion.MediaPlayerSnapshotTaken.pszFilename); OnMediaPlayerSnapshotTaken(fileName); }
private void OnMediaPlayerSnapshotTakenInternal(IntPtr ptr) { #if NET20 || NET35 || NET40 || NET45 var args = (VlcEventArg)Marshal.PtrToStructure(ptr, typeof(VlcEventArg)); #else var args = Marshal.PtrToStructure <VlcEventArg>(ptr); #endif var fileName = Utf8InteropStringConverter.Utf8InteropToString(args.eventArgsUnion.MediaPlayerSnapshotTaken.pszFilename); OnMediaPlayerSnapshotTaken(fileName); }
private void OnMediaPlayerTitleChangedInternal(IntPtr ptr) { #if NET20 || NET35 || NET40 || NET45 var args = (VlcEventArg)Marshal.PtrToStructure(ptr, typeof(VlcEventArg)); #else var args = Marshal.PtrToStructure <VlcEventArg>(ptr); #endif var fileName = Utf8InteropStringConverter.Utf8InteropToString(args.eventArgsUnion.MediaPlayerTitleChanged.NewTitle); OnMediaPlayerTitleChanged(fileName); }
internal static List <TrackDescription> GetSubTrackDescription(IntPtr moduleRef) { var result = new List <TrackDescription>(); if (moduleRef != IntPtr.Zero) { var module = MarshalHelper.PtrToStructure <TrackDescriptionStructure>(moduleRef); var name = Utf8InteropStringConverter.Utf8InteropToString(module.Name); result.Add(new TrackDescription(module.Id, name)); var data = GetSubTrackDescription(module.NextTrackDescription); result.AddRange(data); } return(result); }
internal static FilterModuleDescription GetFilterModuleDescription(ModuleDescriptionStructure module) { if (module.Name == IntPtr.Zero) { return(null); } var result = new FilterModuleDescription { Name = Utf8InteropStringConverter.Utf8InteropToString(module.Name), ShortName = Utf8InteropStringConverter.Utf8InteropToString(module.ShortName), LongName = Utf8InteropStringConverter.Utf8InteropToString(module.LongName), Help = Utf8InteropStringConverter.Utf8InteropToString(module.Help) }; return(result); }
internal static List <TrackDescription> GetSubTrackDescription(IntPtr moduleRef) { var result = new List <TrackDescription>(); if (moduleRef != IntPtr.Zero) { #if NET20 || NET35 || NET40 || NET45 var module = (TrackDescriptionStructure)Marshal.PtrToStructure(moduleRef, typeof(TrackDescriptionStructure)); #else var module = Marshal.PtrToStructure <TrackDescriptionStructure>(moduleRef); #endif var name = Utf8InteropStringConverter.Utf8InteropToString(module.Name); result.Add(new TrackDescription(module.Id, name)); var data = GetSubTrackDescription(module.NextTrackDescription); result.AddRange(data); } return(result); }
private void OnDisplayProgress(IntPtr userdata, IntPtr dialogid, IntPtr title, IntPtr text, bool indeterminate, float position, IntPtr cancel) { string strTitle = Utf8InteropStringConverter.Utf8InteropToString(title); string strText = Utf8InteropStringConverter.Utf8InteropToString(text); string strCancelButton = Utf8InteropStringConverter.Utf8InteropToString(cancel); var cts = new CancellationTokenSource(); this.openDialogsCancellationTokens.Add(dialogid, cts); Task.Run(() => this.currentDialogManager.DisplayProgressAsync(userdata, dialogid, strTitle, strText, indeterminate, position, strCancelButton, cts.Token)) .ContinueWith(task => { if (task.IsCompleted) { this.myManager.DismissDialog(dialogid); } this.openDialogsCancellationTokens.Remove(dialogid); }); }
private void OnUpdateProgress(IntPtr userdata, IntPtr dialogid, float position, IntPtr text) { string strText = Utf8InteropStringConverter.Utf8InteropToString(text); Task.Run(() => this.currentDialogManager.UpdateProgress(userdata, dialogid, position, strText)); }
private void OnMediaPlayerAudioDeviceInternal(IntPtr ptr) { var args = MarshalHelper.PtrToStructure <VlcEventArg>(ptr); OnMediaPlayerAudioDevice(Utf8InteropStringConverter.Utf8InteropToString(args.eventArgsUnion.MediaPlayerAudioDevice.pszDevice)); }