Class YouTubeVideoPlaybackEventArgs
- Namespace
- VisioForge.Core.Types
- Assembly
- VisioForge.Core.dll
Provides data for events related to YouTube video playback, specifically when available video formats are detected.
public class YouTubeVideoPlaybackEventArgs : EventArgsInheritance
Inherited Members
Examples
// Example of handling a YouTubeVideoPlayback event:
void OnYouTubeVideoFormatsDetected(object sender, YouTubeVideoPlaybackEventArgs e)
{
Console.WriteLine($"Found {e.Formats.Count} available formats.");
foreach (var format in e.Formats)
{
Console.WriteLine($" - {format.Resolution}p ({format.Format})");
}
// Select the highest resolution available
e.SelectedFormatIndex = e.Formats.OrderByDescending(f => f.Resolution).ThenBy(f => f.Format.ToString()).ToList().IndexOf(e.Formats.OrderByDescending(f => f.Resolution).ThenBy(f => f.Format.ToString()).First());
Console.WriteLine($"Selected format index: {e.SelectedFormatIndex}");
}
Remarks
This event argument is typically used to inform the application about the various video quality and format options available for a YouTube video, allowing the application to select the preferred format for playback.
Constructors
YouTubeVideoPlaybackEventArgs(List<YouTubeVideoInfo>)
Initializes a new instance of the VisioForge.Core.Types.YouTubeVideoPlaybackEventArgs class.
public YouTubeVideoPlaybackEventArgs(List<YouTubeVideoInfo> formats)Parameters
formatsList<YouTubeVideoInfo>-
A list of available YouTube video formats.
Properties
Formats
Gets a list of available YouTube video formats and their details.
public List<YouTubeVideoInfo> Formats { get; }Property Value
SelectedFormatIndex
Gets or sets the index of the selected video format from the VisioForge.Core.Types.YouTubeVideoPlaybackEventArgs.Formats list.
public int SelectedFormatIndex { get; set; }