Exemplo n.º 1
0
        private async Task PrepareLoresDownload()
        {
            Uri dlInfo;

            try
            {
                var hiresMissing = await PlayableItemVm.CalcAvailability(_appContext, DownloadDefinition.Path);

                dlInfo = await _appContext.XBMC.PrepareDownload(Lores);
            }
            catch (Exception ex)
            {
                Status = DownloadStatus.Error;

                ErrorMessage = ex.Message;
                return;
            }

            DownloadDefinition.Source   = dlInfo;
            DownloadDefinition.Filename = System.IO.Path.ChangeExtension(DownloadDefinition.Filename, "mp4");
            await PrepareDownload();
        }
Exemplo n.º 2
0
        private async Task PrepareTranscoding()
        {
            TranscodeJob = new VlmJob(Vlc);
            var sourceDir       = System.IO.Path.GetDirectoryName(DownloadDefinition.Path);
            var sourceFilename  = System.IO.Path.GetFileNameWithoutExtension(DownloadDefinition.Path);
            var sourceExtension = System.IO.Path.GetExtension(DownloadDefinition.Path);

            Lores = System.IO.Path.Combine(sourceDir, sourceFilename + "_lores.mp4");
            var loresMissing = await PlayableItemVm.CalcAvailability(_appContext, Lores);

            if (loresMissing)
            {
                var sourceUri = new Uri(DownloadDefinition.Path);
                TranscodeJob.PropertyChanged += TranscodeJobPropertyChanged;
                try
                {
                    await
                    TranscodeJob.Transcode(sourceUri.ToString(), Lores, DownloadDefinition.AudioTrack,
                                           DownloadDefinition.SubtitleTrack);
                }
                catch (WebException wex)
                {
                    if (wex.Response != null && ((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.Forbidden)
                    {
                        _appContext.View.ErrorMessage("The VLC rejected the request. Please check the tutorial. (see the chapter \"Access control\")");
                    }
                    Status       = DownloadStatus.Error;
                    ErrorMessage = wex.Message;
                    return;
                }
                Status = DownloadStatus.Transcoding;
            }
            else
            {
                await PrepareLoresDownload();
            }
        }