[vlc-devel] [PATCH 2/2] Added a Task.Delay to wait for the mediaPlayer to start

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Feb 15 10:12:15 CET 2017


On Thu, Feb 9, 2017, at 02:38 AM, Pablo Biagioli wrote:
> ---
>  app/VLC.Core/App.xaml.cs | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/app/VLC.Core/App.xaml.cs b/app/VLC.Core/App.xaml.cs
> index 5672a1bf1..cb873be9d 100644
> --- a/app/VLC.Core/App.xaml.cs
> +++ b/app/VLC.Core/App.xaml.cs
> @@ -214,8 +214,8 @@ namespace VLC
>                                                      subsFd = await
>                                                      StorageFile.GetFileFromPathAsync(subsValue.Value);
>                                                      if(subsFd == null)
>                                                          ToastHelper.Basic("Failed
>                                                          to Load
>                                                          Subtitles:
>                                                          Couln´t find the
>                                                          file.");
> -                                                    else
> if(!StorageApplicationPermissions.FutureAccessList.CheckAccess(subsFd))
> -                                                       
> StorageApplicationPermissions.FutureAccessList.Add(subsFd);
> +                                                    //else
> if(!StorageApplicationPermissions.FutureAccessList.CheckAccess(subsFd))
> +                                                    //   
> StorageApplicationPermissions.FutureAccessList.Add(subsFd);
>                                                      break;
>                                                  case "url":
>                                                      using (var
>                                                      httpClient = new
>                                                      System.Net.Http.HttpClient())
> @@ -258,8 +258,19 @@ namespace VLC
>                                      await
>                                      Locator.MediaPlaybackViewModel.PlayStream(decoder[1].Value);
>                                      if (subsFd != null)
>                                      {
> -                                        ToastHelper.Basic("Subtitles
> Loaded Successfully");
> -                                       
> Locator.MediaPlaybackViewModel.OpenSubtitleCommand.Execute(subsFd);
> +                                        await Task.Run(async () =>
> +                                        {
> +                                            //I should wait until
> _mediaPlayer != null
> +                                            while
> (!Locator.MediaPlaybackViewModel.IsPlaying)
> +                                            {
> +                                                await Task.Delay(10);
> +                                            }
> +                                            await
> Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
> +                                               
> Locator.MediaPlaybackViewModel.OpenSubtitleCommand.Execute(subsFd);
> +                                               
> ToastHelper.Basic("Subtitles Loaded Successfully");
> +                                            });
> +                                            
> +                                        });
>                                      }
>                                          
>                                  }
> -- 
> 2.11.1.windows.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

Hi,

That is not the proper way of doing it. Please use the PlaybackService
events.

Regards,

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list