add extra options

This commit is contained in:
Jelle Luteijn 2024-06-04 11:28:44 +02:00
parent 75c557f565
commit 1e8e9f5c83
2 changed files with 176 additions and 110 deletions

View file

@ -36,6 +36,9 @@
this.btnPause = new System.Windows.Forms.Button();
this.lblPassword = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.btnStop = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnPrevious = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lbHosts
@ -113,12 +116,48 @@
this.txtPassword.TabIndex = 7;
this.txtPassword.Text = "animecon";
//
// btnStop
//
this.btnStop.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnStop.Location = new System.Drawing.Point(12, 291);
this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(192, 23);
this.btnStop.TabIndex = 8;
this.btnStop.Text = "Stop";
this.btnStop.UseVisualStyleBackColor = true;
this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
//
// btnNext
//
this.btnNext.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnNext.Location = new System.Drawing.Point(109, 237);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(96, 23);
this.btnNext.TabIndex = 9;
this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnPrevious
//
this.btnPrevious.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnPrevious.Location = new System.Drawing.Point(12, 237);
this.btnPrevious.Name = "btnPrevious";
this.btnPrevious.Size = new System.Drawing.Size(96, 23);
this.btnPrevious.TabIndex = 10;
this.btnPrevious.Text = "Previous";
this.btnPrevious.UseVisualStyleBackColor = true;
this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(216, 312);
this.ClientSize = new System.Drawing.Size(216, 326);
this.Controls.Add(this.btnPrevious);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.btnStop);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.btnPause);
@ -145,6 +184,9 @@
private System.Windows.Forms.Button btnPause;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnPrevious;
}
}

View file

@ -33,11 +33,35 @@ namespace AnimeCon.Vlc.Starter
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString());
DoWebRequestAsync(item.ToString(), "pl_pause");
}
}
private async Task DoWebRequestAsync(string hostname)
private void btnStop_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_stop");
}
}
private void btnPrevious_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_previous");
}
}
private void btnNext_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_next");
}
}
private async Task DoWebRequestAsync(string hostname, string command)
{
using (HttpClient httpClient = new HttpClient())
{
@ -50,7 +74,7 @@ namespace AnimeCon.Vlc.Starter
try
{
// Make a GET request to the remote XML file
HttpResponseMessage response = await httpClient.GetAsync($"http://{hostname}/requests/status.xml?command=pl_pause");
HttpResponseMessage response = await httpClient.GetAsync($"http://{hostname}/requests/status.xml?command={command}");
// Ensure the request was successful
response.EnsureSuccessStatusCode();