Multimedia Accessibility – How to Check in C#

Accessible Multimedia

Multimedia web accessibility refers to ensuring that multimedia content, such as videos, audio files, and interactive presentations, is accessible to all individuals, including those with disabilities. Multimedia content is prevalent on the internet, and everyone must access and understand the information conveyed. Accessible media must meet all the needs of people with disabilities and must include:

The accessible multimedia is customized for assistive technologies. This means that blind people no longer have to rely on others to read to them. They simply open the browser and interact with the content on their own, as screen reader software is designed to read online content out loud.

Without a caption for an audio file, deaf people cannot recognize the meaningful information that the audio conveys. But captions, if they are well-written and synchronized with the audio content, provide descriptions of critical visual details and actions in multimedia.

We already covered how to check alt text for images, buttons, and more in the Screen Reader Accessibility article. Here, we will look at the importance of using a <track> element for multimedia accessibility.

<track> Element to Provide Audio & Video Descriptions

Video content cannot be seen by visually impaired people, and audio content cannot be heard by hearing-impaired people. The primary purpose of the <track> element is to provide captions and subtitles for video and audio content. While it’s not intended for providing audio descriptions directly, it can be used in conjunction with other methods to make audio descriptions available for individuals with visual impairments.

Captions for Video

The use of the video alt text is not a standard or recommended practice in HTML. The alt attribute is primarily used for providing alternative text for images and is not intended for <video> elements. However, there are alternative approaches to making video content accessible.

Captions in the video include a textual description of all essential background noises and other sounds and the text of all dialogue and narration. The <video> element must include a <track> element with kind="captions" property. Captions must convey all relevant auditory information in the video, including dialogue, musical cues, sound effects, and other vital data for deaf users.

Here’s how you can use the <track> element for multimedis accessibility:

1<video poster="myvideo.png" controls>
2    <source src="myvideo.mp4" srclang="en" type="video/mp4">
3    <source src="myvideo.webm" srclang="fr" type="video/webm">
4    <source src="myvideo.webm" srclang="ua" type="video/webm"> 
5    <track src="myvideo_en.vtt" kind="captions" srclang="en" label="English">
6    <track src="myvideo_fr.ttml" kind="captions" srclang="fr" label="French">
7    <track src="mvideo_ua.vtt" kind="captions" srclang="ua" label="Ukrainian">
8</video>

Let’s look at line 5 of the HTML code. The src attribute of the <track> element specifies the track file name and points to the WebVTT file (“myvideo_en.vtt”) containing the captions or subtitles. The kind attribute describes the contents of the file. The srclang attribute specifies the language of the track file. The label attribute specifies the track name. None of these attributes, except src, are required. However, they are highly recommended as they improve clarity.

Captions for Audio

Ensure all elements with audio content on the website have a caption using the <track> element with kind="captions" property. Captions are text—synchronized with the audio file—of the dialog, narration, and any important auditory information, for the benefit of deaf users. The following code shows how to add two different tracks – one in English and one in Spanish:

1<audio>
2   <source src="mySpeech.mp3" type="audio/mp3">
3   <track src="captions_en.vtt" kind="captions" srclang="en" label="english_captions">
4   <track src="captions_es.vtt" kind="captions" srclang="es" label="spanish_captions">
5</audio>

Audio Description for <video> elements

Adding audio descriptions to <video> elements is a crucial accessibility practice, ensuring that individuals with visual impairments can fully understand and enjoy video content. While blind people can hear the audio content of videos with no issue, they miss the visual aspects of films, such as facial expressions and scenes. Many things happen in movies that are completely visual, with no auditory component. For example, a person can make a facial expression but not speak. Audio descriptions provide narrated information about the visual elements of a video, such as scenes, actions, and gestures.

The following code shows how to add two different audio descriptions – one in English and one in Spanish:

1<video width="300" height="200">
2    <source src="myVideo.mp4" type="video/mp4">
3    <track src="audio_desc_en.vtt" kind="descriptions" srclang="en" label="english_description">
4    <track src="audio_desc_es.vtt" kind="descriptions" srclang="es" label="spanish_description">
5</video>

Check Multimedia Accessibility with Aspose.HTML

To check your website for the multimedia accessibility criteria, you need to follow these steps:

  1. Use the WebAccessibility() constructor to create an instance of the WebAccessibility class responsible for web accessibility validation.
  2. Use the Rules property of the webAccessibility object that provides access to a collection of web accessibility rules.
    • Call the GetPrinciple() method of the AccessibilityRules class and GetGuideline() method of the Principle class to get required principle by code from WCAG.
  3. Call the CreateValidator() method to create a validator object. You are essentially setting up a validator that will check web content against the specific accessibility guidelines and success criteria associated with the guideline you’ve specified.
  4. Load an HTML document using one of the HTMLDocument() constructors.
  5. Use the Validate(document) method to check the HTML document for accessibility. The result is stored in the validationResult variable.
  6. Check whether the validation was successful. Print the detailed information about errors, including the associated HTML element.

In this example, you can check an HTML document for compliance with all the criteria in the “1.2 Time-based Media” guideline.

 1// Initialize a webAccessibility container
 2WebAccessibility webAccessibility = new WebAccessibility();
 3
 4// Get from the rules list Principle "1.Perceivable" by code "1" and get guideline "1.2 Time-based Media"
 5Guideline guideline = webAccessibility.Rules.GetPrinciple("1").GetGuideline("1.2");
 6
 7//Create an accessibility validator, pass the found guideline as parameters, and specify the full validation settings
 8AccessibilityValidator validator = webAccessibility.CreateValidator(guideline, ValidationBuilder.All);
 9
10// Initialize an HTMLDocument object
11using (HTMLDocument document = new HTMLDocument("https://www.youtube.com/watch?v=Yugq1KyZCI0&t=4s"))
12{
13    // Check the document
14    ValidationResult validationResult = validator.Validate(document);
15
16    // Checking for success
17    if (!validationResult.Success)
18    {
19        // Get all result details
20        foreach (RuleValidationResult ruleResult in validationResult.Details)
21        {
22            // If the result of the rule is unsuccessful
23            if (!ruleResult.Success)
24            {
25
26                // Get an errors list
27                foreach (ITechniqueResult result in ruleResult.Errors)
28                {
29                    // Check the type of the erroneous element
30                    if (result.Error.Target.TargetType == TargetTypes.HTMLElement)
31                    {
32                        HTMLElement rule = (HTMLElement)result.Error.Target.Item;
33                        Console.WriteLine("Error in rule {0} : {1}", result.Rule.Code, result.Error.ErrorMessage);
34                        Console.WriteLine("HTML Element: {0}", rule.OuterHTML);
35                    }
36                }
37            }
38        }
39    }
40}

To check, for example, the presence of audio description, you must select the desired criterion and make a check on it.

 1    // Get from the rules list Principle "1.Perceivable" by code "1" and get guideline "1.2 Time-based Media"
 2    var guideline = webAccessibility.Rules.GetPrinciple("1").GetGuideline("1.2");
 3
 4    // Get criterion – 1.2.3 Audio Description or Media Alternative (Prerecorded)
 5    var criterion = guideline.GetCriterion("1.2.3");
 6    
 7    // Create an accessibility validator – and pass the found guideline as parameters and specify the full validation settings
 8    var validator = webAccessibility.CreateValidator(criterion, ValidationBuilder.All);
 9
10    ...

Remember that the key is to ensure that users with disabilities can access the multimedia content and understand its context effectively. Combining multiple accessibility techniques, such as captions, transcripts, and audio descriptions, can provide all users with a comprehensive and inclusive experience.

See Also

  • In the chapter Web Accessibility Check, you will learn how to check website accessibility for all WCAG compliance or only meet specific criteria using classes and methods of the Aspose.Html.Accessibility and Aspose.Html.Accessibility.Results namespaces.
  • The article How to Improve Website Accessibility explains how to make your website accessible to users and how to check your website for WCAG compliance using the Aspose.HTML API for .NET.
  • The article Screen Reader Accessibility explains how to design a website for screen reader accessibility in accordance with WCAG guidelines using the Aspose.HTML for .NET API.
  • Check out the article Сolor Сontrast Accessibility if you want to learn how to properly adjust the contrast of your web content to WCAG standards, the world authority on web accessibility. You will discover how to test color contrast accessibility using C# and make your web content easy to read for all users.
  • In the article Web Accessibility Rules, you will learn how to use the AccessibilityRules class, which is a repository of WCAG 2 requirements, success criteria, and techniques, for web accessibility checks.
  • The article Errors and Warning discusses the classes and interfaces that help collect information about errors and warnings during website accessibility testing. It focuses on the failure criteria and methods that report errors, and provides a C# example for retrieving web accessibility errors after testing an HTML document.

Aspose.HTML offers free online Web Accessibility Checker. This tool scans web pages, validates them for WCAG compliance, identifies problems, and suggests improvements. Get instant insights into your website’s compliance, allowing you to determine the scope of necessary corrections and the gap between the current state of your website or HTML document and WCAG requirements.

Text “Web Accessibility Checker”

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.