├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.txt
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example4job1
│ │ └── example4job1
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── drawable
│ │ ├── default_cover.png
│ │ ├── login.png
│ │ └── music_player.png
│ ├── java
│ │ └── com
│ │ │ └── example4job1
│ │ │ └── musicplayer
│ │ │ ├── activity
│ │ │ ├── ListActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── PlayActivity.java
│ │ │ ├── Song.java
│ │ │ └── SongAdapter.java
│ │ │ └── service
│ │ │ └── MusicService.java
│ ├── layout
│ │ ├── activity_list.xml
│ │ ├── activity_login.xml
│ │ ├── activity_play.xml
│ │ ├── content_play.xml
│ │ └── song_item.xml
│ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ ├── res
│ │ ├── drawable
│ │ │ ├── default_cover.png
│ │ │ ├── image.png
│ │ │ ├── login.png
│ │ │ ├── music_player.png
│ │ │ ├── play.png
│ │ │ ├── sound.png
│ │ │ ├── sound2.png
│ │ │ └── stop.png
│ │ ├── layout
│ │ │ ├── activity_list.xml
│ │ │ ├── activity_login.xml
│ │ │ ├── activity_play.xml
│ │ │ └── song_item.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example4job1
│ └── example4job1
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── 开发文档
├── Android移动终端开发大作业_黎为楷.doc
├── MusicPlayer.apk
└── 运行效果截图.zip
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | 阅读【开发文档】
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.qinposhi.example4job1"
8 | minSdkVersion 24
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation 'com.android.support:design:24.2.1'
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 | implementation 'com.android.support:appcompat-v7:24.2.1'
29 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example4job1/example4job1/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.example4job1;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.qinposhi.example4job1", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
19 |
20 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/drawable/default_cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/drawable/default_cover.png
--------------------------------------------------------------------------------
/app/src/main/drawable/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/drawable/login.png
--------------------------------------------------------------------------------
/app/src/main/drawable/music_player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/drawable/music_player.png
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/activity/ListActivity.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.activity;
2 |
3 | import android.Manifest;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.IntentFilter;
8 | import android.content.pm.PackageManager;
9 | import android.database.Cursor;
10 | import android.os.Bundle;
11 | import android.provider.MediaStore;
12 | import android.support.v4.app.ActivityCompat;
13 | import android.support.v4.content.ContextCompat;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.view.View;
16 | import android.widget.AdapterView;
17 | import android.widget.Button;
18 | import android.widget.ListView;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import com.example4job1.R;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | public class ListActivity extends AppCompatActivity {
28 |
29 | private IntentFilter intentFilter;
30 | private HeadsetPlugReceiver headsetPlugReceiver;
31 | private List songArray = new ArrayList();
32 | public String Songpath;
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_list);
37 |
38 | intentFilter = new IntentFilter();
39 | intentFilter.addAction("android.intent.action.HEADSET_PLUG");
40 | headsetPlugReceiver = new HeadsetPlugReceiver();
41 | registerReceiver(headsetPlugReceiver, intentFilter);
42 | TextView welcomeTxt=(TextView)findViewById(R.id.txt_welcome);
43 | Button backBtn=(Button)findViewById(R.id.btn_back);
44 | String uname=this.getIntent().getStringExtra("uname");
45 | welcomeTxt.setText("欢迎您,"+uname+"!");
46 |
47 | backBtn.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | Intent intent=new Intent(ListActivity.this, LoginActivity.class);
51 | startActivity(intent);
52 | }
53 | });
54 |
55 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
56 | ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }, 1);
57 | } else {
58 | initSongs();
59 | }
60 |
61 | ListView songList=(ListView)findViewById(R.id.list_song);
62 | SongAdapter myAdapter=new SongAdapter(ListActivity.this,R.layout.song_item,songArray);
63 | songList.setAdapter(myAdapter);
64 | songList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
65 | @Override
66 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
67 | Song song = songArray.get(position);
68 | Songpath = song.getSongPath();
69 | Toast.makeText(ListActivity.this, Songpath, Toast.LENGTH_SHORT).show();
70 | Intent intent=new Intent(ListActivity.this, PlayActivity.class);
71 | intent.putExtra("position",Songpath);
72 | startActivity(intent);
73 | }
74 | });
75 |
76 | }
77 |
78 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
79 | switch (requestCode) {
80 | case 1:
81 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
82 | initSongs();
83 | } else {
84 | Toast.makeText(this, "未授权,功能无法实现", Toast.LENGTH_SHORT).show();
85 | }
86 | break;
87 | default:
88 | }
89 | }
90 |
91 |
92 | public void initSongs() {
93 |
94 | Cursor cursor = null;
95 | cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
96 | if (cursor != null) {
97 | while (cursor.moveToNext()) {
98 | String artist = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
99 | String disName = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
100 | String url = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
101 | Song song = new Song(disName, artist, url);
102 | songArray.add(song);
103 | }
104 | }
105 | }
106 |
107 |
108 | class HeadsetPlugReceiver extends BroadcastReceiver {
109 | @Override
110 | public void onReceive(Context context, Intent intent) {
111 | if(intent.getAction().equalsIgnoreCase("android.intent.action.HEADSET_PLUG")){
112 | if(intent.hasExtra("state")){
113 | if (intent.getIntExtra("state", 0) == 1){
114 | Toast.makeText(context, "耳机已连接", Toast.LENGTH_SHORT).show();
115 | }else{
116 | Toast.makeText(context, "耳机已断开", Toast.LENGTH_SHORT).show();
117 | }
118 | }
119 | }
120 | }
121 | }
122 |
123 | protected void onDestroy() {
124 | super.onDestroy();
125 | unregisterReceiver(headsetPlugReceiver);
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/activity/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.activity;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.CheckBox;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import com.example4job1.R;
14 |
15 | public class LoginActivity extends AppCompatActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 |
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_login);
22 | final EditText unameEdt=(EditText)findViewById(R.id.edt_username);
23 | final EditText pwdEdt=(EditText)findViewById(R.id.edt_password);
24 | SharedPreferences pref = getSharedPreferences("Userinfo",MODE_PRIVATE);
25 | unameEdt.setText(pref.getString("uname",""));
26 | Button quitBtn=(Button)findViewById(R.id.btn_quit);
27 | Button loginBtn=(Button)findViewById(R.id.btn_login);
28 | final CheckBox savenameChk=(CheckBox)findViewById(R.id.chk_savename);
29 |
30 | quitBtn.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | android.os.Process.killProcess(android.os.Process.myPid());
34 | System.exit(0);
35 | }
36 | });
37 |
38 | loginBtn.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | if(unameEdt.getText().toString()==null||unameEdt.getText().toString().equals("") || !pwdEdt.getText().toString().equals("123456")){
42 | Toast.makeText(LoginActivity.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
43 | }else{
44 | SharedPreferences.Editor editor= getSharedPreferences("Userinfo",MODE_PRIVATE).edit();
45 | if(savenameChk.isChecked() == true){
46 | editor.putString("uname",unameEdt.getText().toString());
47 | }
48 | else {
49 | editor.putString("uname","");
50 | }
51 | editor.apply();
52 | Intent intent=new Intent(LoginActivity.this,ListActivity.class);
53 | intent.putExtra("uname",unameEdt.getText().toString());
54 | startActivity(intent);
55 | }
56 | }
57 | });
58 |
59 |
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/activity/PlayActivity.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.activity;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.media.MediaPlayer;
7 | import android.os.Bundle;
8 | import android.os.Handler;
9 | import android.os.Message;
10 | import android.support.v4.app.ActivityCompat;
11 | import android.support.v4.content.ContextCompat;
12 | import android.support.v7.app.AppCompatActivity;
13 | import android.view.View;
14 | import android.widget.Button;
15 | import android.widget.SeekBar;
16 | import android.widget.TextView;
17 | import android.widget.Toast;
18 |
19 | import com.example4job1.R;
20 |
21 | public class PlayActivity extends AppCompatActivity {
22 |
23 | private MediaPlayer mediaPlayer = new MediaPlayer();
24 | SeekBar volumeBar;
25 | SeekBar positionBar;
26 | Button playBtn;
27 | int totalTime;
28 | TextView elapsedTimeLabel;
29 | TextView remainingTimeLabel;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_play);
35 | playBtn = (Button) findViewById(R.id.playBtn);
36 | playBtn.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View view) {
39 | if (!mediaPlayer.isPlaying()) {
40 | mediaPlayer.start();
41 | playBtn.setBackgroundResource(R.drawable.stop);
42 |
43 | } else {
44 | mediaPlayer.pause();
45 | playBtn.setBackgroundResource(R.drawable.play);
46 | }
47 | }
48 | });
49 |
50 | if(ContextCompat.checkSelfPermission(PlayActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
51 | ActivityCompat.requestPermissions(PlayActivity.this,new String[]{
52 | Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
53 | } else {
54 | initMediaPlayer();
55 | }
56 |
57 | elapsedTimeLabel = (TextView) findViewById(R.id.elapsedTimeLabel);
58 | remainingTimeLabel = (TextView) findViewById(R.id.remainingTimeLabel);
59 | totalTime = mediaPlayer.getDuration();
60 |
61 | positionBar = (SeekBar) findViewById(R.id.positionBar);
62 | positionBar.setMax(totalTime);
63 | positionBar.setOnSeekBarChangeListener(
64 | new SeekBar.OnSeekBarChangeListener() {
65 | @Override
66 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
67 | if (fromUser) {
68 | mediaPlayer.seekTo(progress);
69 | positionBar.setProgress(progress);
70 | }
71 | }
72 |
73 | @Override
74 | public void onStartTrackingTouch(SeekBar seekBar) {
75 |
76 | }
77 |
78 | @Override
79 | public void onStopTrackingTouch(SeekBar seekBar) {
80 |
81 | }
82 | }
83 | );
84 |
85 | volumeBar = (SeekBar) findViewById(R.id.volumeBar);
86 | volumeBar.setOnSeekBarChangeListener(
87 | new SeekBar.OnSeekBarChangeListener() {
88 | @Override
89 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
90 | float volumeNum = progress / 100f;
91 | mediaPlayer.setVolume(volumeNum, volumeNum);
92 | }
93 | @Override
94 | public void onStartTrackingTouch(SeekBar seekBar) {
95 |
96 | }
97 | @Override
98 | public void onStopTrackingTouch(SeekBar seekBar) {
99 |
100 | }
101 | }
102 | );
103 |
104 | new Thread(new Runnable() {
105 | @Override
106 | public void run() {
107 | while (mediaPlayer != null) {
108 | try {
109 | Message msg = new Message();
110 | if(!mediaPlayer.isPlaying()) break;
111 | msg.what = mediaPlayer.getCurrentPosition();
112 | handler.sendMessage(msg);
113 | Thread.sleep(1000);
114 | } catch (InterruptedException e) {}
115 |
116 | }
117 | }
118 | }).start();
119 |
120 | }
121 |
122 | private Handler handler = new Handler() {
123 | @Override
124 | public void handleMessage(Message msg) {
125 | int currentPosition = msg.what;
126 | positionBar.setProgress(currentPosition);
127 | String elapsedTime = createTimeLabel(currentPosition);
128 | elapsedTimeLabel.setText(elapsedTime);
129 | String remainingTime = createTimeLabel(totalTime-currentPosition);
130 | remainingTimeLabel.setText("- " + remainingTime);
131 | }
132 | };
133 |
134 | public String createTimeLabel(int time) {
135 | String timeLabel = "";
136 | int min = time / 1000 / 60;
137 | int sec = time / 1000 % 60;
138 | timeLabel = min + ":";
139 | if (sec < 10) timeLabel += "0";
140 | timeLabel += sec;
141 | return timeLabel;
142 | }
143 |
144 | public void initMediaPlayer(){
145 |
146 | Intent intent = getIntent();
147 | String currentIndex = intent.getStringExtra("position");
148 | try{
149 | mediaPlayer.setDataSource(currentIndex);
150 | mediaPlayer.prepare();
151 |
152 | } catch (Exception e){
153 | e.printStackTrace();
154 | }
155 | }
156 |
157 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
158 | switch (requestCode) {
159 | case 1:
160 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
161 | initMediaPlayer();
162 | } else {
163 | Toast.makeText(this, "未授权,功能无法实现", Toast.LENGTH_SHORT).show();
164 | finish();
165 | }
166 | break;
167 | default:
168 | }
169 |
170 | }
171 |
172 | protected void onDestroy(){
173 | super.onDestroy();
174 | if (mediaPlayer!=null){
175 | mediaPlayer.stop();
176 | mediaPlayer.release();
177 | }
178 | }
179 |
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/activity/Song.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.activity;
2 |
3 | public class Song {
4 |
5 | private String songName;
6 | private String singer;
7 | public String songPath;
8 |
9 | public Song(String songName,String singer,String songPath){
10 | this.singer=singer;
11 | this.songName=songName;
12 | this.songPath=songPath;
13 | }
14 |
15 | public String getSongName(){return songName;}
16 | public String getSinger(){return singer;}
17 | public String getSongPath(){return songPath;}
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/activity/SongAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.activity;
2 |
3 |
4 | import android.content.Context;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.example4job1.R;
13 |
14 | import java.util.List;
15 |
16 | public class SongAdapter extends ArrayAdapter {
17 | private int resourceId;
18 |
19 | public SongAdapter(Context context, int textViewResourceId,
20 | List objects) {
21 | super(context, textViewResourceId, objects);
22 | resourceId = textViewResourceId;
23 | }
24 |
25 | @Override
26 | public View getView(int position, View convertView, ViewGroup parent) {
27 |
28 | Song song = getItem(position);
29 | View view;
30 | ViewHolder viewHolder;
31 | if (convertView == null) {
32 | view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
33 | viewHolder = new ViewHolder();
34 | viewHolder.coverImg = (ImageView) view.findViewById (R.id.img_cover);
35 | viewHolder.songNameTxt = (TextView) view.findViewById (R.id.txt_song_name);
36 | viewHolder.singerTxt = (TextView) view.findViewById (R.id.txt_singer);
37 | view.setTag(viewHolder);
38 | } else {
39 | view = convertView;
40 | viewHolder = (ViewHolder) view.getTag();
41 | }
42 |
43 | viewHolder.songNameTxt.setText(song.getSongName());
44 | viewHolder.singerTxt.setText(song.getSinger());
45 | viewHolder.songPath=song.getSongPath();
46 | return view;
47 | }
48 |
49 | class ViewHolder {
50 | ImageView coverImg;
51 | TextView songNameTxt;
52 | TextView singerTxt;
53 | String songPath;
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example4job1/musicplayer/service/MusicService.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.musicplayer.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.database.Cursor;
6 | import android.media.MediaPlayer;
7 | import android.os.Binder;
8 | import android.os.IBinder;
9 | import android.provider.MediaStore;
10 |
11 | /*下列代码完成了Service各种状态下所进行的操作,目的是在Service运行时保证MediaPlayer的存在,
12 | 而在service被停止时使MediaPlayer销毁。Service在后台持续运行
13 | **/
14 | public class MusicService extends Service {
15 |
16 | private MediaPlayer mediaPlayer = new MediaPlayer();
17 | private MusicBinder mBinder = new MusicBinder(); //获取MusicBinder的实例
18 | /*创建一个MusicBinder类,让它继承自Binder,然后在它的内部提供了initMediaPlayer方法**/
19 | public class MusicBinder extends Binder {
20 |
21 | public void initMediaPlayer(){
22 | Cursor cursor = null;
23 | try{
24 | cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
25 | null, null, null, null);
26 | if (cursor!=null) {
27 | while(cursor.moveToNext()) {
28 |
29 | mediaPlayer.setDataSource(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)));
30 | mediaPlayer.prepare();
31 |
32 | }
33 | }
34 |
35 | } catch (Exception e){
36 | e.printStackTrace();
37 | }
38 | }
39 |
40 | }
41 |
42 | //在onBinder方法中返回这个实例
43 | public IBinder onBind(Intent intent){
44 | return mBinder;
45 | }
46 |
47 | @Override
48 | public void onCreate()
49 | {
50 | super.onCreate();
51 | mBinder.initMediaPlayer();
52 |
53 | }
54 |
55 |
56 | public int onStartCommand(Intent intent, int flags, int id)
57 | {
58 | //mediaPlayer.reset();
59 | if (!mediaPlayer.isPlaying()){
60 | mediaPlayer.start();
61 | }
62 | return super.onStartCommand(intent, flags, id);
63 | }
64 |
65 | @Override
66 | public void onDestroy()
67 | {
68 | super.onDestroy();
69 | if (mediaPlayer.isPlaying()) {
70 | mediaPlayer.stop();
71 | mediaPlayer.release();
72 | }
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
26 |
27 |
28 |
32 |
33 |
34 |
38 |
39 |
45 |
46 |
53 |
54 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
23 |
24 |
25 |
32 |
33 |
36 |
42 |
43 |
46 |
47 |
48 |
53 |
59 |
60 |
65 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/layout/activity_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/layout/content_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/layout/song_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
20 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/default_cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/default_cover.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/image.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/login.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/music_player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/music_player.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sound.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/sound.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sound2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/sound2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/drawable/stop.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
23 |
24 |
25 |
32 |
33 |
36 |
42 |
43 |
46 |
47 |
48 |
53 |
59 |
60 |
65 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
19 |
22 |
28 |
34 |
35 |
36 |
40 |
41 |
47 |
48 |
49 |
50 |
56 |
60 |
61 |
67 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/song_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
20 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 10dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Music
3 | Player
4 | 请输入用户名
5 | 请输入密码
6 | 登陆
7 | 返回
8 | PlayActivity
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 10dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Music
3 | Player
4 | 请输入用户名
5 | 请输入密码
6 | 登陆
7 | 返回
8 | PlayActivity
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example4job1/example4job1/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example4job1.example4job1;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | maven{ url 'https://maven.aliyun.com/repository/google'}
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects{
18 | repositories {
19 | maven{ url 'https://maven.aliyun.com/repository/google'}
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Nov 15 14:10:15 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/开发文档/Android移动终端开发大作业_黎为楷.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/开发文档/Android移动终端开发大作业_黎为楷.doc
--------------------------------------------------------------------------------
/开发文档/MusicPlayer.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/开发文档/MusicPlayer.apk
--------------------------------------------------------------------------------
/开发文档/运行效果截图.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DIWEIKA/Android_MusicPlayer/bb2e0b6705bd9d3f68300898f040b4f2eb8ea208/开发文档/运行效果截图.zip
--------------------------------------------------------------------------------