Пример #1
0
        public override void OnInitializing()
        {
            if (Player.curVideoPlugin == null || Player.curVideoPlugin.PluginName != PluginName)
            {
                return;
            }
            if (Session.CurVideoStream != null && Session.CurVideoStream.DecoderInput.Stream is TorrentStream)
            {
                ((TorrentStream)Session.CurVideoStream.DecoderInput.Stream).Cancel();
            }

            try
            {
                base.OnInitialized();
                bitSwarm?.Dispose();
                Torrent?.Dispose();
                bitSwarm            = null;
                Torrent             = null;
                sortedPaths         = null;
                downloadNextStarted = false;
                cfg.EnableBuffering = false;
            } catch (Exception e)
            {
                Log("Error ... " + e.Message);
            }
        }
Пример #2
0
        public OpenVideoResults OpenVideo()
        {
            try
            {
                if (SuRGeoNix.BitSwarmLib.BitSwarm.ValidateInput(Player.Session.InitialUrl) == SuRGeoNix.BitSwarmLib.BitSwarm.InputType.Unkown)
                {
                    return(null);
                }

                isOpening = true;
                bitSwarm  = new SuRGeoNix.BitSwarmLib.BitSwarm(cfg);
                bitSwarm.MetadataReceived += MetadataReceived;
                bitSwarm.OnFinishing      += OnFinishing;

                bitSwarm.Open(Player.Session.InitialUrl);
                Log("Starting");
                bitSwarm.Start();

                if (sortedPaths != null)
                {
                    isOpening = false;
                    return(new OpenVideoResults(VideoStreams[0]));
                }

                isOpening = false;
                return(new OpenVideoResults()
                {
                    runAsync = true
                });
            }
            catch (Exception e)
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(e.Message, "completed or is invalid"))
                {
                    isOpening = false;
                    MetadataReceived(this, new SuRGeoNix.BitSwarmLib.BitSwarm.MetadataReceivedArgs(bitSwarm.torrent));
                    return(new OpenVideoResults()
                    {
                        runAsync = true
                    });
                }

                Log("Error ... " + e.Message);
            }

            isOpening = false;
            return(new OpenVideoResults()
            {
                forceFailure = true
            });
        }