public TorrentRandomAccessStream(TorrentStreamManager manager)
 {
     _manager = manager;
     _torrentFile = manager.TorrentVideoFile;
     _torrent = manager.Torrent;
     var stream = File.Open(Path.Combine(_torrentFile.TargetFolder.Path, _torrentFile.Path), FileMode.Open,
         FileAccess.Read, FileShare.ReadWrite);
     _internalStream = stream.AsRandomAccessStream();
 }
        public TorrentRandomAccessStream(TorrentStreamManager manager)
        {
            _manager     = manager;
            _torrentFile = manager.TorrentVideoFile;
            _torrent     = manager.Torrent;
            var stream = File.Open(Path.Combine(_torrentFile.TargetFolder.Path, _torrentFile.Path), FileMode.Open,
                                   FileAccess.Read, FileShare.ReadWrite);

            _internalStream = stream.AsRandomAccessStream();
        }
 public void Stop()
 {
     var managerCopy = StreamManager;
     StreamManager.TorrentManager.TorrentStateChanged += (sender, args) =>
     {
         if (args.NewState == TorrentState.Stopped)
         {
             _engine.Unregister(managerCopy.TorrentManager);
             File.Delete(Path.Combine(managerCopy.TorrentVideoFile.TargetFolder.Path, managerCopy.TorrentVideoFile.Path));
         }
     };
     StreamManager.Dispose();
     StreamManager = null;
 }
 public void CreateManager(MagnetLink link)
 {
     var manager = link.CreateManager(_engine.Settings.SaveFolder);
     _engine.Register(manager);
     StreamManager = new TorrentStreamManager(manager);
 }
 public void CreateManager(InfoHash hash)
 {
     var manager = hash.CreateManager(_engine.Settings.SaveFolder);
     _engine.Register(manager);
     StreamManager = new TorrentStreamManager(manager);
 }
 public void CreateManager(Torrent torrent)
 {
     var manager = torrent.CreateManager(_engine.Settings.SaveFolder);
     _engine.Register(manager);
     StreamManager = new TorrentStreamManager(manager);
 }