private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            MainWindow.HideContent();
            Helper.DisableScreenSaver();
            MainWindow.videoPlayback = true;
            media                      = new FFProbe();
            media.ToolPath             = Environment.GetFolderPath(SpecialFolder.ApplicationData);
            VolumeSlider.Value         = Player.Volume = Properties.Settings.Default.Volume;
            VolumeSlider.ValueChanged += VolumeSlider_ValueChanged;
            Focus();
            Player.MediaOpened += (s, ev) => MediaOpenedEvent();
            while (true)
            {
                Animate();
                await Task.Run(() => {
                    Thread.Sleep(1080);
                });

                file = GetSource();
                if (file != null && downloader.Status.Progress > 0.01)
                {
                    try {
                        var duration   = media.GetMediaInfo(file).Duration.TotalSeconds;
                        var downloaded = duration * downloader.Status.Progress;
                        if (File.Exists(file) && duration != 0 && downloaded > 10)
                        {
                            Player.Source = new Uri(file);
                            Player.Stop();
                            break;
                        }
                    } catch (Exception) { }
                }
            }
            TorrentDatabase.Save(downloader.TorrentSource);

            Animate();
            await Task.Delay(1080);

            Player.MediaFailed += (s, ev) => MediaFailedEvent();
            Player.MediaEnded  += (s, ev) => MediaFinishedEvent();
            var sb    = (Storyboard)FindResource("OpacityDown");
            var clone = sb.Clone();

            clone.Completed += (s, ev) => {
                Middle.Visibility = Visibility.Collapsed;
            };
            sb.Begin(Middle);
        }
Ejemplo n.º 2
0
        private TorrentDownloader DownloadLocal(bool sequential)
        {
            if (TorrentSession == null)
            {
                TorrentSession = new Session();
                TorrentSession.ListenOn(6881, 6889);
            }
            var torrentParams = new AddTorrentParams();

            torrentParams.SavePath = GetDownloadPath();
            torrentParams.Url      = TorrentSource.Magnet;
            Handle = TorrentSession.AddTorrent(torrentParams);
            SetDownloadSpeedLimit(Settings.DownloadSpeed);
            SetUploadSpeedLimit(Settings.UploadSpeed);
            Handle.SequentialDownload = TorrentSource.IsSequential = sequential;
            Status = Handle.QueryStatus();
            torrents.Add(this);
            TorrentDatabase.Save(TorrentSource);
            return(this);
        }