Skip to main content

Form1 class

Files: EZInfiniteYTLive/Form1.cs (logic) and Form1.Designer.cs (generated layout) Namespace: EZInfiniteYTLive Type: public partial class Form1 : Form

Form1 is the application's single window. It is a thin controller: it reads/validates user input, and delegates all actual streaming work to a VideoStreamer instance that it owns.

Fields​

FieldTypeDefaultDescription
_videoFolderstringstring.EmptyAbsolute path to the folder of videos chosen via Choose Videos.
_streamerVideoStreamernullThe currently active streaming engine instance, or null when idle.
_shuffleboolfalseTracks whether the user selected RandOrder? and passes that choice to VideoStreamer.
_ffmpegPathstring"ffmpeg.exe"Path/command used to invoke FFmpeg. Comment in source: // Adjust if needed. It is resolved from the current directory or system PATH before streaming starts.

Designer-generated controls​

These are defined in Form1.Designer.cs and referenced by the logic in Form1.cs:

ControlTypeNotes
RMTPUrlTextBoxPre-filled with rtmp://a.rtmp.youtube.com/live2.
StreamKeyTextBoxPasswordChar = '*' masks the input.
ChooseVideosButtonButtonText: "Choose Videos".
StartButtonButtonText: "START".
ForceStopButtonButtonText: "STOP".
StatusLabelLabelShows current app status.
ShuffleRadioRadioButtonText: "RandOrder?".
AlphabeticOrderRadioRadioButtonText: "AlphabeticOrder?"; TabStop = true and checked by default (set in the Form1 constructor).

Constructor​

Form1()​

public Form1()
{
InitializeComponent();
StatusLabel.Text = "Idle";
this.Text = "EZ Infinite YT Live - Idle";
this.FormClosed += (s, e) =>
{
if (_streamer != null)
{
_streamer.Dispose();
}
};
AlphabeticOrderRadio.Checked = true;
}
  • Calls InitializeComponent() to build the designer-defined UI.
  • Initializes the status label and window title to reflect an idle state.
  • Registers a FormClosed handler that disposes the active VideoStreamer when the window is closed. Disposal requests a stop, signals the worker, kills the active FFmpeg process, and briefly waits for the worker to finish.
  • Defaults the playback order to alphabetic by checking AlphabeticOrderRadio.

Event handlers​

ChooseVideosButton_Click​

private void ChooseVideosButton_Click(object sender, EventArgs e)

Opens a FolderBrowserDialog. If the user confirms a selection:

  • Stores the chosen path in _videoFolder.
  • Updates StatusLabel.Text to "Selected: {_videoFolder}".

StartButton_Click​

private void StartButton_Click(object sender, EventArgs e)

Validates input and starts a stream:

  1. Returns early with a MessageBox error if _videoFolder is empty or the directory no longer exists.
  2. Reads and trims RMTPUrl.Text and StreamKey.Text.
  3. Returns early with a MessageBox error if either the RTMP URL or stream key is empty.
  4. Builds fullRtmp: concatenates the RTMP URL and stream key, inserting a / separator only if the URL doesn't already end with one:
    string fullRtmp = rtmpUrl.EndsWith("/") ? rtmpUrl + streamKey : rtmpUrl + "/" + streamKey;
  5. Disposes any pre-existing _streamer (defensive cleanup).
  6. Resolves _ffmpegPath through VideoStreamer.TryResolveFfmpegPath; if FFmpeg is missing, shows an error and does not start a worker.
  7. Constructs a new VideoStreamer(resolvedFfmpegPath, _videoFolder, fullRtmp, _shuffle).
  8. Subscribes to ErrorOccurred so background FFmpeg and folder errors are shown in the status label.
  9. Updates UI state: StatusLabel.Text = "Streaming...", disables StartButton, enables ForceStopButton, and updates the window title.
  10. Calls _streamer.StartStreaming() to begin the background loop.

ForceStopButton_Click​

private void ForceStopButton_Click(object sender, EventArgs e)

Stops the active stream, if any:

  1. Calls _streamer.StopStreaming() then _streamer.Dispose(), and sets _streamer = null.
  2. Resets StatusLabel.Text to "Stopped" and the window title accordingly.
  3. Re-enables StartButton and disables ForceStopButton.

ShuffleRadio_CheckedChanged / AlphabeticOrderRadio_CheckedChanged​

private void ShuffleRadio_CheckedChanged(object sender, EventArgs e)
private void AlphabeticOrderRadio_CheckedChanged(object sender, EventArgs e)

Mutually-exclusive radio buttons (standard WinForms RadioButton group behavior) update the _shuffle boolean:

  • Checking ShuffleRadio sets _shuffle = true.
  • Checking AlphabeticOrderRadio sets _shuffle = false.

The selected value is passed to each new VideoStreamer, so it controls the order used for every playlist pass.

Lifecycle summary​