Exemplo n.º 1
0
        private void ChangeChannelTo(ChannelInfo channel, string number)
        {
            if (channel == null)
            {
                MessageBox.Show(Strings.NOT_FOUND_CH + number);
            }
            else
            {
                if (ParentalControl.Get().IsChBlock(channel))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                Logger.Current.Info($"[ChangeChannelTo] Change channel to {channel.TVGName}");
                playerForm.Stop();
                playerForm.SetIsChannel(channel.ChannelType == ChType.CHANNEL);
                playerForm.SetIsPaused(false);
                Thread.Sleep(500);
                currLang = -1;
                currSub  = -1;
                int currPostion = 0;
                if (channel.currentPostion != null && !channel.seen)
                {
                    if (MessageBox.Show(owner: this, Strings.Resume, "AmiIptvPlayer", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        currPostion = (int)channel.currentPostion;
                    }
                    else
                    {
                        channel.currentPostion = null;
                        SeenResumeChannels.Get().RemoveResume(channel.Title);
                        RefreshListView();
                    }
                }
                playerForm.SetMedia(channel.URL, currPostion, currLang, currSub);
                try
                {
                    string        chName = channel.TVGName.Length < 100 ? channel.TVGName : channel.TVGName.Substring(0, 99);
                    Task <string> stats  = Utils.GetAsync("http://amian.es:5085/stats?ctype=connected&app=net&chn=" + chName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR SENDING STATS");
                }

                logoChannel.LoadCompleted -= logoLoaded;

                logoChannel.Image = Image.FromFile("./resources/images/nochannel.png");
                if (!string.IsNullOrEmpty(channel.TVGLogo))
                {
                    logoChannel.LoadAsync(channel.TVGLogo);
                    logoChannel.LoadCompleted += logoLoaded;
                }

                string title = channel.Title;
                if (title.Length > 20)
                {
                    title = title.Substring(0, 20) + "...";
                }
                lbChName.Text = title;
                chnl          = channel;
                currentChType = channel.ChannelType;
                SetEPG(channel);
            }
            playerForm.SetFocusOnVideoPanel();
        }