Beispiel #1
0
        public static async Task InitiateBackgroundTransferAsync(string path)
        {
            try
            {
                string          filename = path.Substring(path.LastIndexOf("/") + 1);
                PrepareDownload download = await App.Context.Connection.Xbmc.Files.PrepareDownloadAsync(path);

                Uri sourceUri = App.Context.Connection.Xbmc.GetFileUri(download.Details.Path);

                const string targetDirectory = "/shared/transfers/";

                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (!isoStore.DirectoryExists(targetDirectory))
                    {
                        isoStore.CreateDirectory(targetDirectory);
                    }
                }

                Uri downloadUri = new Uri(targetDirectory + filename, UriKind.RelativeOrAbsolute);

                var request = new BackgroundTransferRequest(sourceUri, downloadUri);
                request.Tag = filename;
                request.TransferProgressChanged += OnTransferProgressChanged;
                request.TransferStatusChanged   += OnTransferStatusChanged;

                BackgroundTransferService.Add(request);
                BackgroundTransferRequestStateChanged?.Raise(request, DownloadRequestState.Initialized);

                string message = string.Format(AppResources.Global_Downloads_Started_Format, filename);
                MessageBox.Show(message, AppResources.Global_Downloads, MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                App.TrackException(ex);
            }
        }
Beispiel #2
0
 public void PrepareDownloadTest()
 {
     PrepareDownload request = new PrepareDownload();
     var             result  = JsonConvert.DeserializeObject <KodiJSON.Files.Response.PrepareDownloadResponse>(ExecuteTest.GetResponse(request));
 }