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
| Field | Type | Default | Description |
|---|---|---|---|
_videoFolder | string | string.Empty | Absolute path to the folder of videos chosen via Choose Videos. |
_streamer | VideoStreamer | null | The currently active streaming engine instance, or null when idle. |
_shuffle | bool | false | Tracks whether the user selected RandOrder? and passes that choice to VideoStreamer. |
_ffmpegPath | string | "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:
| Control | Type | Notes |
|---|---|---|
RMTPUrl | TextBox | Pre-filled with rtmp://a.rtmp.youtube.com/live2. |
StreamKey | TextBox | PasswordChar = '*' masks the input. |
ChooseVideosButton | Button | Text: "Choose Videos". |
StartButton | Button | Text: "START". |
ForceStopButton | Button | Text: "STOP". |
StatusLabel | Label | Shows current app status. |
ShuffleRadio | RadioButton | Text: "RandOrder?". |
AlphabeticOrderRadio | RadioButton | Text: "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
FormClosedhandler that disposes the activeVideoStreamerwhen 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.Textto"Selected: {_videoFolder}".
StartButton_Click
private void StartButton_Click(object sender, EventArgs e)
Validates input and starts a stream:
- Returns early with a
MessageBoxerror if_videoFolderis empty or the directory no longer exists. - Reads and trims
RMTPUrl.TextandStreamKey.Text. - Returns early with a
MessageBoxerror if either the RTMP URL or stream key is empty. - 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; - Disposes any pre-existing
_streamer(defensive cleanup). - Resolves
_ffmpegPaththroughVideoStreamer.TryResolveFfmpegPath; if FFmpeg is missing, shows an error and does not start a worker. - Constructs a new
VideoStreamer(resolvedFfmpegPath, _videoFolder, fullRtmp, _shuffle). - Subscribes to
ErrorOccurredso background FFmpeg and folder errors are shown in the status label. - Updates UI state:
StatusLabel.Text = "Streaming...", disablesStartButton, enablesForceStopButton, and updates the window title. - Calls
_streamer.StartStreaming()to begin the background loop.
ForceStopButton_Click
private void ForceStopButton_Click(object sender, EventArgs e)
Stops the active stream, if any:
- Calls
_streamer.StopStreaming()then_streamer.Dispose(), and sets_streamer = null. - Resets
StatusLabel.Textto"Stopped"and the window title accordingly. - Re-enables
StartButtonand disablesForceStopButton.
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
ShuffleRadiosets_shuffle = true. - Checking
AlphabeticOrderRadiosets_shuffle = false.
The selected value is passed to each new VideoStreamer, so it controls the order used for every playlist pass.