Android fast and easy to implement music player

Source: Internet
Author: User
Tags add time

The player features are as follows:

1. Pause, play
2. Drag bar implementation, fast forward, rewind
3. Sync Lyrics
4. Next song, last one.
5. Album Image display
6. Background playback, notice bar display
7. Call, pause, end of call, start playing.
The interface is as follows:

When playing, there will be an icon in the notification bar. Paused, Icon disappears

Background playback, will be displayed in the notification bar, click, you can enter the playback interface

Use details:
Download the music player module code to githob.
Add: Music player module code download
After downloading, unzip and import the project into eclipse.

The project as a library, introduced into the project using
1. Project Introduction
Create a project, click Item, right button, Properties,android,add
As the diagram interface:

Add time, select just you download the imported items, click OK


2. Configure Androidmanifest.xml
Access Network 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>
An interface UI used by activity to play music
Service, a service to play music


3. OK, the project inside to use:
In use, you only need to use a intent, the corresponding data into, start playmusicactivity can
First put your data in the array, Musicean is a music entity class, in the downloaded source code can see its related properties, some of the information stored music. Like underneath.
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 is a collection of data that you put together.
Intent.putextra ("id", 0); The location of the collection beans to get the corresponding music object
Intent.putextra ("type", "net"); is online or local, online fill net, local, casually fill
StartActivity (Intent);
}
Music,id,type, no change.

All right, finish it.
Demo Download Address: Musicplayerdemo


Note that this demo needs and address: Music player module code to download the use of, music player module code, is the playback module, demo is the application of how to use the module.
The module code is completely transparent, we can more have their own needs, modify the code, modify the interface, there are detailed comments

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.