Exemplo n.º 1
0
        public override async void OnNavigatedTo(object parameter, NavigationMode mode, Dictionary<string, object> state)
        {
            if (mode == NavigationMode.Back)
            {
                _navigationService.GoBack();
                return;
            }

            PlaybackTorrent = (PlaybackTorrent) parameter;
            if (!string.IsNullOrEmpty(PlaybackTorrent.TorrentUrl))
            {
                State = TorrentStreamManager.State.Metadata;
                var torrent = await Torrent.LoadAsync(new Uri(PlaybackTorrent.TorrentUrl), "");
                _torrentStreamService.CreateManager(torrent);
            }
            else if (!string.IsNullOrEmpty(PlaybackTorrent.MagnetLink))
            {
                var magnetLink = new MagnetLink(PlaybackTorrent.MagnetLink);
                _torrentStreamService.CreateManager(magnetLink);
            }
            else
            {
                var hash = InfoHash.FromHex(PlaybackTorrent.TorrentHash);
                _torrentStreamService.CreateManager(hash);
            }
            _torrentStreamService.StreamManager.StreamProgress += StreamManagerOnStreamProgress;
            _torrentStreamService.StreamManager.StreamReady += StreamManagerOnStreamReady;
            _torrentStreamService.StreamManager.Error += StreamManagerOnError;
            _torrentStreamService.StreamManager.StartDownload();
            State = _torrentStreamService.StreamManager.CurrentState;
        }
Exemplo n.º 2
0
 public void CreateManager(MagnetLink link)
 {
     var manager = link.CreateManager(_engine.Settings.SaveFolder);
     _engine.Register(manager);
     StreamManager = new TorrentStreamManager(manager);
 }