Skip to main content

Python print() Function

When you start learning Python, one of the first things you need to learn is how to display information on the screen. For example, you might want to display: A welcome message. Your name and age. The result of a mathematical calculation. Student marks and results. Information generated by a Python program. Python provides a built-in function called print() for displaying information. The print() function is one of the simplest and most frequently used functions in Python. It helps programmers display information while testing programs, solving problems, and developing applications. In this article, we will learn how to use print() with practical examples and their outputs. 1. What Is the print() Function in Python? The print() function is a built-in Python function that displays information in the output area, usually the terminal or console. Let's look at a simple example. print("Hello, World!") Output: Hello, World! In this example, Python displays the text Hello,...

HTML Audio and Video – Adding Multimedia to Webpages

Modern websites are no longer limited to text and images. Today’s websites include:

  • Music

  • Videos

  • Podcasts

  • Tutorials

  • Animations

  • Live streaming

HTML5 introduced built-in support for audio and video without needing external plugins like Adobe Flash.

In this article, we will learn:

  • HTML audio tag

  • HTML video tag

  • Multimedia formats

  • Audio and video attributes

  • Autoplay and controls

  • Multiple media sources

  • YouTube embedding

  • Responsive multimedia

  • Practical examples


What is Multimedia in HTML?

Multimedia refers to media elements such as:

  • Audio

  • Video

  • Animation

HTML5 provides multimedia support using:

  • <audio>

  • <video>

Before HTML5, websites depended on plugins like Adobe Flash Player.

Today, browsers support multimedia directly.


HTML Audio

The <audio> tag is used to play sound files.

Supported audio:

  • Songs

  • Podcasts

  • Voice recordings

  • Background music


Basic Audio Syntax

<audio controls>

    <source src="song.mp3"
            type="audio/mpeg">

</audio>

Explanation

ElementPurpose
<audio>Creates audio player
controlsDisplays play buttons
<source>Specifies audio file
typeAudio file format

Simple Audio Example

<!DOCTYPE html>
<html>

<head>
    <title>HTML Audio</title>
</head>

<body>

    <h1>Audio Example</h1>

    <audio controls>

        <source src="music.mp3"
                type="audio/mpeg">

    </audio>

</body>

</html>

Output Features

Browser displays:

  • Play button

  • Pause button

  • Volume control

  • Progress bar


Common Audio Formats

FormatExtension
MP3.mp3
WAV.wav
OGG.ogg

MP3 Format

Most widely supported format.

Example:

song.mp3

Audio Controls Attribute

The controls attribute shows audio controls.

Example:

<audio controls>

Without controls, users cannot operate audio easily.


Autoplay Audio

Automatically starts audio.

Example:

<audio autoplay controls>

Loop Audio

Repeats audio continuously.

Example:

<audio loop controls>

Muted Audio

Starts audio in muted mode.

Example:

<audio muted controls>

Multiple Audio Sources

Different browsers support different formats.

Example:

<audio controls>

    <source src="music.mp3"
            type="audio/mpeg">

    <source src="music.ogg"
            type="audio/ogg">

</audio>

Browser selects the supported format automatically.


Fallback Text

If browser does not support audio:

<audio controls>

    <source src="music.mp3"
            type="audio/mpeg">

    Your browser does not support audio.

</audio>

HTML Video

The <video> tag is used to display videos.

Supported videos:

  • Tutorials

  • Movies

  • Advertisements

  • Lectures

  • Product demos


Basic Video Syntax

<video controls width="500">

    <source src="movie.mp4"
            type="video/mp4">

</video>

Simple Video Example

<!DOCTYPE html>
<html>

<head>
    <title>HTML Video</title>
</head>

<body>

    <h1>Video Example</h1>

    <video controls width="500">

        <source src="video.mp4"
                type="video/mp4">

    </video>

</body>

</html>

Common Video Formats

FormatExtension
MP4.mp4
WebM.webm
OGG.ogv

MP4 Format

Most popular and widely supported video format.

Example:

movie.mp4

Video Width and Height

Example:

<video width="600"
       height="400"
       controls>

Video Poster Attribute

Displays an image before video starts.

Example:

<video controls
       poster="thumbnail.jpg">

Autoplay Video

Example:

<video autoplay controls>

Many browsers restrict autoplay with sound.


Loop Video

Example:

<video loop controls>

Muted Video

Example:

<video muted controls>

Multiple Video Sources

Example:

<video controls width="500">

    <source src="movie.mp4"
            type="video/mp4">

    <source src="movie.webm"
            type="video/webm">

</video>

Complete Multimedia Example

<!DOCTYPE html>
<html>

<head>
    <title>Multimedia Example</title>
</head>

<body>

    <h1>HTML Audio</h1>

    <audio controls>

        <source src="music.mp3"
                type="audio/mpeg">

    </audio>

    <hr>

    <h1>HTML Video</h1>

    <video controls width="500">

        <source src="movie.mp4"
                type="video/mp4">

    </video>

</body>

</html>

Embedding YouTube Videos

Websites often embed videos from YouTube.

YouTube provides iframe embed code.

Example:

<iframe width="560"
        height="315"
        src="https://www.youtube.com/embed/VIDEO_ID">

</iframe>

What is an Iframe?

An iframe embeds another webpage inside a webpage.

Used for:

  • Videos

  • Maps

  • External content


Google Maps Embed Example

Maps from Google can also be embedded.

Example:

<iframe src="https://maps.google.com">

</iframe>

Responsive Video

Responsive videos adjust according to screen size.

Example:

<video width="100%"
       controls>

Why Responsive Multimedia is Important

Necessary for:

  • Mobile phones

  • Tablets

  • Smart TVs

  • Laptops

Companies like Netflix and YouTube heavily rely on responsive media systems.


HTML5 Multimedia Advantages

Before HTML5:

  • Plugins required

  • Compatibility issues

  • Security problems

HTML5 multimedia:

  • Faster

  • More secure

  • Plugin-free

  • Mobile friendly


Accessibility in Multimedia

Accessibility improves usability.

Best practices:

  • Add subtitles

  • Use captions

  • Provide transcript text

  • Avoid autoplay with sound


Subtitle Support

Using <track> tag.

Example:

<video controls>

    <source src="movie.mp4"
            type="video/mp4">

    <track src="subtitles.vtt"
           kind="subtitles">

</video>

HTML Audio vs Video

FeatureAudioVideo
Tag<audio><video>
Media TypeSoundVisual + Sound
DimensionsNot neededWidth and height needed

Real-Life Uses of Multimedia

Audio Used In

  • Music apps

  • Podcasts

  • Meditation apps

  • Audiobooks

Video Used In

  • Streaming platforms

  • Online classes

  • Video tutorials

  • Social media

Platforms like Spotify, Netflix, and YouTube are heavily based on multimedia technologies.


Common Mistakes Beginners Make

1. Wrong File Path

Wrong:

<source src="video.mp">

Correct:

<source src="video.mp4">

2. Unsupported File Formats

Some browsers may not support all formats.

Use multiple sources.


3. Missing Controls

Without controls, users cannot play media.

Wrong:

<video>

Correct:

<video controls>

4. Large Video Files

Large media files:

  • Slow websites

  • Consume internet

  • Affect performance

Always optimize media.


Best Practices for Multimedia

  • Compress media files

  • Use modern formats

  • Add subtitles

  • Avoid excessive autoplay

  • Make media responsive

  • Use lazy loading when possible


Conclusion

HTML multimedia allows websites to include audio and video directly without external plugins. This makes modern websites interactive, educational, and engaging.

Comments

Popular posts from this blog

Understanding Comments in Java: A Beginner’s Guide

When learning Java programming, one of the first concepts you’ll come across is comments . Comments may not affect how a program runs, but they play a crucial role in making code more understandable, readable, and maintainable. Let’s dive deeper into what comments are, why they’re important, and the different types of comments in Java. What are Comments in Java? A comment in Java is a piece of text written within a program that is ignored by the compiler . In other words, comments are notes for humans, not instructions for machines. They help developers explain the purpose of code, describe logic, or temporarily disable certain lines of code without deleting them. Why are Comments Important? ๐Ÿ“Œ Readability – Comments make code easier to understand for you and others. ๐Ÿ“Œ Maintenance – When you revisit your code after months, comments remind you what you were doing. ๐Ÿ“Œ Collaboration – In team projects, comments explain code to fellow developers. ๐Ÿ“Œ Debugging – You c...

Java Program to Check Voting Eligibility

In this program, we’ll take the user’s age as input and check whether the person is eligible to vote or not. In India, the minimum age required to vote is 18 years . ๐Ÿ’ป Program Code // Java Program to Check Voting Eligibility import java.util.Scanner; public class VotingEligibility { public static void main(String[] args) { // Create Scanner object to take input from user Scanner sc = new Scanner(System.in); // Ask user to enter age System.out.print("Enter your age: "); int age = sc.nextInt(); // Check eligibility if (age >= 18) { System.out.println("You are eligible to vote."); } else { System.out.println("You are not eligible to vote yet."); System.out.println("You can vote after " + (18 - age) + " year(s)."); } sc.close(); // Close the scanner } } ๐Ÿง  Explanation import java.util.Scanner; → Imp...

Java Program to Calculate Total Marks and Average of Five Subjects

๐Ÿ’ก Program Explanation In this program: The user will input marks of five subjects . The program will calculate the total marks and average . It will then display both results clearly. ๐Ÿง‘‍๐Ÿ’ป Java Code: // Java Program to Calculate Total Marks and Average of Five Subjects import java.util.Scanner; // Importing Scanner class for user input public class TotalAndAverage { public static void main(String[] args) { // Creating Scanner object to take input from user Scanner sc = new Scanner(System.in); // Declaring variables for five subjects double subject1, subject2, subject3, subject4, subject5; // Taking marks input for each subject System.out.print("Enter marks of Subject 1: "); subject1 = sc.nextDouble(); System.out.print("Enter marks of Subject 2: "); subject2 = sc.nextDouble(); System.out.print("Enter marks of Subject 3: "); subject3 = sc.nextDo...