private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            button.IsEnabled = false;

            channelName = name.Text;

            tasks = new List <Task>();
            //忽略https憑證問題
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);

            tb.Text += "頻道名稱:" + channelName;
            tb.Text += Environment.NewLine + "正在建立執行個體...";
            tb.Text += Environment.NewLine + "建立成功";
            tb.Text += Environment.NewLine + "正在查詢是否有開台...";

            //accessToken = TwitchService.GetClientAccessToken();

            bool state = TwitchService.GetStreamState(TwitchService.GetChannelIdByName(channelName));

            if (!state)
            {
                throw new ApplicationException("沒有開台");
            }

            twitchService = new TwitchService(channelName, TextAction, StateAction);

            Task task = new Task(() =>
            {
                twitchService.DownloadWrapper();
            });

            tasks.Add(task);

            tb.Text += Environment.NewLine + "開始下載已直播之部分...";
            task.Start();

            tb.Text += Environment.NewLine + "開始15秒一次的開台狀態偵測...";


            timer = new Timer(15000)
            {
                AutoReset = true,
                Enabled   = true
            };
            timer.Elapsed += twitchService.TimerHandler;
            timer.Start();
        }
Exemple #2
0
 private void TimerHandler(object sender, ElapsedEventArgs e)
 {
     CheckOutputDirectory("temp" + Id);
     VodPlaylist vodPlaylists = TwitchService.RetrieveVodPlaylist("temp" + Id, playlistUrl);
 }