Android quick and simple music player implementation

Source: Internet
Author: User

The player functions are as follows:

1. Pause and play
2. Implement dragging, fast forward, and fast return
3. Synchronization of lyrics
4. Next song, last song.
5. album Image Display
6. Background playback. The notification bar is displayed.
7. Call, pause, stop, and start playing.
The interface is as follows:

During playback, an icon is displayed in the notification bar. Pause, icon disappears

When playing in the background, it will be displayed in the notification bar. Click to go To the playback page.

Usage Details:
Download the code of the music player module from GIthob.
Address: Download the music player module code
After the download, decompress the package and import the project to eclipse.

Use a project as a library and introduce it to the project.
1. Introduce the project
Create a project, right-click the project, right-click the project, properties, android, and add
Interface:

When adding, select the project you just downloaded and imported, and click OK


2. Configure AndroidManifest. xml
Network Access Permissions:
<Uses-permission android: name = "android. permission. INTERNET"/>
Configure activity and service:
<Activity android: name = "com. hck. music. ui. PlayMusicActivity"> </activity>
<Service android: name = "com. hck. music. server. PlayMusicServer"> </service>
Ui used by activity to play music
Service for playing music


3. All right, use it in the project:
When using PlayMusicActivity, you only need to use an intent to upload the corresponding data and start PlayMusicActivity.
First, put your data in an array. Musicean is a music entity class. You can see its attributes in the downloaded source code and save music information. For example
Private ArrayList <MusicBean> beans;
Public void playMusic1 (View view) {// click a button to play the video
Intent intent = new Intent ();
Intent. setClass (this, PlayMusicActivity. class );
Intent. putExtra ("music", beans. toArray (); // beans are a set of data that you have installed.
Intent. putExtra ("id", 0); // gets the corresponding music object at the position of the Set beans
Intent. putExtra ("type", "net"); // whether it is online or local. Enter "net" online or "local ".
StartActivity (intent );
}
// Music, id, type, cannot be changed

OK.
Demo: musicPlayerdemo


Note: This demo must be used with the address: Download the code of the music player module. The code of the music player module is the playback module. The demo shows how to use this module in applications.
The module code is completely transparent. You can modify the code, modify the interface, and annotate the code in detail.

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.