Android media playback-media playback (1)

Source: Internet
Author: User

This article translated from: http://developer.android.com/guide/topics/ui/index.html

Android Multimedia Framework supports playing a variety of popular media types, so it is easy to integrate audio, video, and images into applications. You can use mediaplayer APIs to play back media files (raw resources) stored in application resources, media files from independent file systems, or data streams over network connections.

This article describes how to write a media playback application that interacts with users, and how to enable the system to achieve good performance and user experience.

Note: Only the audio data can be played to the standard output device. At present, it is mainly mobile device microphones or Bluetooth headsets. Audio files cannot be played during audio sessions.

Basic

The following classes are used to play sound and video in the android framework:

Mediaplayer: this class is the main API for playing sound and video.

Audiomanager: This class manages audio resources and audio output on devices.

List Declaration

Before using mediaplayer for development on an application, make sure that the Application List contains declarations that allow the use of relevant functions.

1. Internet permission: to use mediaplayer to play Internet-based content streams, applications must apply for Internet access permissions.

<Uses-Permission Android: Name = "android. Permission. Internet"/>

2. wake lock permission: if the player application needs to remain in the dimming state, or sleep state of the processor, or use mediaplayer. setscreenonwhileplaying () or mediaplayer. the setwakemode () method must apply for this permission.

<Uses-permissionandroid: Name = "android. Permission. wake_lock"/>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.