Ejemplo n.º 1
0
 public StartDownloadVm(PlayableItemVm playableItemVm, StorageType defaultStorage, IAppContext appContext)
 {
     _playableItemVm = playableItemVm;
     _defaultStorage = defaultStorage;
     _appContext     = appContext;
     StartDownload   = new DelegateCommand(StartDownloadExecute);
     Target          = defaultStorage == StorageType.VideoLibrary ? "Video Library" : "Audio Library";
     FileName        = _playableItemVm.GetDownloadName();
     Transcode       = true;
     AudioTrack      = new UndefinedTrackVm(_appContext);
     Subtitle        = new UndefinedTrackVm(_appContext);
     AudioTracks     = new List <TrackVm>()
     {
         AudioTrack
     };
     Subtitles = new List <TrackVm>()
     {
         Subtitle
     };
     LoadDetails();
 }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
        public void PrepareDownload(PlayableItemVm playableItemVm, StorageType defaultStorage)
        {
            var vm = new StartDownloadVm(playableItemVm, defaultStorage, _appContext);

            _appContext.View.PrepareDownload(vm);
        }