0% found this document useful (0 votes)
12 views2 pages

Media Player in Android

The MediaPlayer class in Android allows playing audio and video with minimal setup. It fetches, decodes and plays media from local resources, internal URIs or external URLs. Permissions like internet access may be required. Alternative classes like ExoPlayer and AudioManager are also discussed.

Uploaded by

pseuhoet65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Media Player in Android

The MediaPlayer class in Android allows playing audio and video with minimal setup. It fetches, decodes and plays media from local resources, internal URIs or external URLs. Permissions like internet access may be required. Alternative classes like ExoPlayer and AudioManager are also discussed.

Uploaded by

pseuhoet65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Explain media player in android

Frequency

Certainly! In Android, the MediaPlayer class is a fundamental component of the


media framework. It allows you to play both audio and video with minimal setup.
Let’s explore the key points about MediaPlayer:

1. MediaPlayer Basics:

Purpose: The MediaPlayer class fetches, decodes, and plays audio and
video.

Media Sources Supported:

Local Resources: You can play audio or video from media files stored
in your application’s resources (raw resources).

Internal URIs: Obtain URIs from a Content Resolver (e.g., accessing


media files from the device’s storage).

External URLs (Streaming): Play media from external sources via


URLs.

For a list of media formats supported by Android, refer to the Supported


Media Formats page.

2. Example: Playing Local Audio:

Suppose you have an audio file saved as a local raw resource (e.g.,
R.raw.sound_file_1 ). You can create a MediaPlayer object like this:

MediaPlayer mediaPlayer = MediaPlayer.create(context,


R.raw.sound_file_1);

The MediaPlayer will handle decoding and playback.

3. Permissions:

Ensure your app’s manifest includes the necessary permissions:

Internet Permission: If streaming network-based content.

Explain media player in android 1


<uses-permission android:name="android.permission.IN
TERNET" />

Wake Lock Permission: If preventing screen dimming or processor


sleep during playback.

<uses-permission android:name="android.permission.WA
KE_LOCK" />

4. Other Relevant Classes:

AudioManager: Manages audio sources and output on the device.

ExoPlayer: An alternative customizable open-source library that supports


high-performance features not available in MediaPlayer.

Remember, MediaPlayer simplifies audio and video playback in Android


applications! 🎵🎥📱
If you’re interested in exploring other media player apps for Android, here are
some options:

VLC for Android: A versatile open-source video and music player1.

MX Player: Known for its extensive format support and features2.

MediaMonkey: Offers advanced media management features2.

ASD Music and Video Player: A lightweight option for audio and video
playback2.

Video Player All Format: Supports various video formats2.

Visha: A simple and efficient media player2.

Explain media player in android 2

You might also like