├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── clearlee
│ │ └── lockscreenmusiccontrol
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── clearlee
│ │ │ └── lockscreenmusiccontrol
│ │ │ ├── App.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MusicPlayService.java
│ │ │ ├── adapter
│ │ │ └── MusicAdapter.java
│ │ │ ├── bean
│ │ │ └── LocalMusicInfo.java
│ │ │ ├── constant
│ │ │ └── MusicConstants.java
│ │ │ ├── controller
│ │ │ └── MusicController.java
│ │ │ ├── mediasession
│ │ │ └── MediaSessionManager.java
│ │ │ └── util
│ │ │ ├── Common.java
│ │ │ ├── LogTool.java
│ │ │ ├── MusicUtil.java
│ │ │ └── ThreadManager.java
│ └── res
│ │ ├── drawable
│ │ ├── bg_white_yuanjiao.xml
│ │ └── music_progressbar.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── item_music_list.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── currplay_music_qq.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── music_button_pause.png
│ │ ├── music_button_play.png
│ │ ├── music_local.png
│ │ ├── next_music.png
│ │ └── pre_music.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── clearlee
│ └── lockscreenmusiccontrol
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.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/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 1.8
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.clearlee.lockscreenmusiccontrol"
8 | minSdkVersion 15
9 | targetSdkVersion 22
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | }
31 |
--------------------------------------------------------------------------------
/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:\android\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/clearlee/lockscreenmusiccontrol/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol;
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.clearlee.lockscreenmusiccontrol", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/App.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol;
2 |
3 | import android.app.Application;
4 |
5 | import com.clearlee.lockscreenmusiccontrol.bean.LocalMusicInfo;
6 | import com.clearlee.lockscreenmusiccontrol.util.MusicUtil;
7 | import com.clearlee.lockscreenmusiccontrol.util.ThreadManager;
8 |
9 | import java.util.HashSet;
10 |
11 | /**
12 | * Created by Clearlee on 2017/12/26 0026.
13 | */
14 |
15 | public class App extends Application {
16 |
17 | private static App app;
18 | public static boolean scanMusicFinish;
19 | public MainActivity activity;
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | app = this;
25 | scanMusic();
26 | }
27 |
28 | public static App getApp() {
29 | return app;
30 | }
31 |
32 | private void scanMusic() {
33 | ThreadManager.getExecutorService().execute(new Runnable() {
34 | @Override
35 | public void run() {
36 | HashSet data = MusicUtil.getInstance().getLocalMusicData();
37 | if (data != null && data.size() > 0) {
38 | MusicUtil.getInstance().getPlayMusicList().addAll(data);
39 | }
40 | scanMusicFinish = true;
41 | }
42 | });
43 |
44 | }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol;
2 |
3 | import android.os.Bundle;
4 | import android.os.Handler;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.ImageView;
9 | import android.widget.ListView;
10 | import android.widget.SeekBar;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.clearlee.lockscreenmusiccontrol.adapter.MusicAdapter;
15 | import com.clearlee.lockscreenmusiccontrol.bean.LocalMusicInfo;
16 | import com.clearlee.lockscreenmusiccontrol.controller.MusicController;
17 | import com.clearlee.lockscreenmusiccontrol.util.Common;
18 | import com.clearlee.lockscreenmusiccontrol.util.LogTool;
19 | import com.clearlee.lockscreenmusiccontrol.util.MusicUtil;
20 |
21 | import java.util.List;
22 |
23 | import static com.clearlee.lockscreenmusiccontrol.MusicPlayService.PLAT_STATE_NORAML;
24 | import static com.clearlee.lockscreenmusiccontrol.MusicPlayService.PLAY_STATE_PAUSED;
25 | import static com.clearlee.lockscreenmusiccontrol.MusicPlayService.PLAY_STATE_PLAYING;
26 |
27 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
28 |
29 | private ImageView ivMusicPlay, ivPre, ivNext;
30 | private SeekBar sb_music;
31 | private TextView currTime, totalTime, emptyView;
32 | private ListView mListView;
33 | private Handler scanMusicHandler = new Handler();
34 | private TextView musicName, musicAuthor;
35 | private MusicAdapter mAdapter;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_main);
41 | App.getApp().activity = this;
42 | init();
43 | }
44 |
45 | private void init() {
46 | initView();
47 | initData();
48 | initService();
49 | }
50 |
51 | private void initService() {
52 | MusicController.initMusicService();
53 | }
54 |
55 | private void initData() {
56 | scanMusicHandler.postDelayed(new Runnable() {
57 | @Override
58 | public void run() {
59 | if (App.scanMusicFinish) {
60 | List data = MusicUtil.getInstance().getPlayMusicList();
61 | if (data != null && data.size() > 0) {
62 | initListViewData(data);
63 | } else {
64 | mListView.setVisibility(View.GONE);
65 | emptyView.setVisibility(View.VISIBLE);
66 | }
67 | } else {
68 | scanMusicHandler.postDelayed(this, 500);
69 | }
70 | }
71 | }, 100);
72 | }
73 |
74 | private void initListViewData(final List data) {
75 |
76 | if (data != null && data.size() > 0) {
77 | data.get(0).setSelectedInShouye(true);
78 | updateMusicInfo(data.get(0));
79 | }
80 |
81 | mAdapter = new MusicAdapter(this, data);
82 | mListView.setAdapter(mAdapter);
83 | mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
84 | @Override
85 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
86 | LocalMusicInfo musicInfo = data.get(position);
87 |
88 | updateCurMusic(musicInfo);
89 |
90 | if (MusicPlayService.musicPlayService.curPlayState == PLAT_STATE_NORAML) {
91 | startPlay(musicInfo);
92 | } else {
93 | resetAndStartPlay(musicInfo);
94 | }
95 | }
96 | });
97 | }
98 |
99 | private void notifyListViewDataChange(LocalMusicInfo musicInfo) {
100 | changeListBackground(musicInfo);
101 | if (mAdapter != null)
102 | mAdapter.notifyDataSetChanged();
103 | }
104 |
105 | private void changeListBackground(LocalMusicInfo musicInfo) {
106 | List data = MusicUtil.getInstance().getPlayMusicList();
107 | for (int i = 0; i < data.size(); i++) {
108 | if (musicInfo.getName().equals(data.get(i).getName())) {
109 | data.get(i).setSelectedInShouye(true);
110 | } else {
111 | data.get(i).setSelectedInShouye(false);
112 | }
113 | }
114 | }
115 |
116 | private void updateMusicInfo(LocalMusicInfo musicInfo) {
117 | LogTool.s("updateMusicInfo");
118 | musicName.setText(musicInfo.getName());
119 | musicAuthor.setText(musicInfo.getAuthor());
120 | sb_music.setProgress(0);
121 | }
122 |
123 | private void initView() {
124 | ivMusicPlay = (ImageView) findViewById(R.id.iv_music_play);
125 | ivPre = (ImageView) findViewById(R.id.iv_pre);
126 | ivNext = (ImageView) findViewById(R.id.iv_next);
127 | sb_music = (SeekBar) findViewById(R.id.sb_music);
128 | currTime = (TextView) findViewById(R.id.tv_curr_play_time);
129 | totalTime = (TextView) findViewById(R.id.tv_total_play_time);
130 | musicName = (TextView) findViewById(R.id.tv_name);
131 | musicAuthor = (TextView) findViewById(R.id.tv_author);
132 | emptyView = (TextView) findViewById(R.id.emptyView);
133 | mListView = (ListView) findViewById(R.id.musiclist);
134 | ivMusicPlay.setOnClickListener(this);
135 | ivPre.setOnClickListener(this);
136 | ivNext.setOnClickListener(this);
137 | sb_music.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
138 | @Override
139 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
140 | int needPlayPosition = (int) (progress / 100.0 * MusicPlayService.musicPlayService.mMediaPlyer.getDuration());
141 | MusicPlayService.musicPlayService.mMediaPlyer.seekTo(needPlayPosition);
142 | }
143 |
144 | @Override
145 | public void onStartTrackingTouch(SeekBar seekBar) {
146 |
147 | }
148 |
149 | @Override
150 | public void onStopTrackingTouch(SeekBar seekBar) {
151 |
152 | }
153 | });
154 | }
155 |
156 | public void refreshTime(int position) {
157 | int progress = (int) (((position / (float) MusicUtil.getInstance().getCurrPlayMusicInfo().getDuration())) * 100);
158 | LogTool.s("refreshTime progress = " + progress);
159 | sb_music.setProgress(progress);
160 | currTime.setText(Common.getSecDuration2HMSFormatString(position / 1000));
161 | totalTime.setText(Common.getSecDuration2HMSFormatString((int) MusicUtil.getInstance().getCurrPlayMusicInfo().getDuration() / 1000));
162 | }
163 |
164 | public void updateImage() {
165 | switch (MusicPlayService.musicPlayService.curPlayState) {
166 | case PLAY_STATE_PLAYING:
167 | ivMusicPlay.setImageResource(R.mipmap.music_button_play);
168 | break;
169 | case PLAY_STATE_PAUSED:
170 | ivMusicPlay.setImageResource(R.mipmap.music_button_pause);
171 | break;
172 | case PLAT_STATE_NORAML:
173 | ivMusicPlay.setImageResource(R.mipmap.music_button_pause);
174 | break;
175 | }
176 | }
177 |
178 | @Override
179 | public void onClick(View v) {
180 | switch (v.getId()) {
181 | case R.id.iv_music_play:
182 | handleMusicControl();
183 | break;
184 | case R.id.iv_pre:
185 | handlePreControl();
186 | break;
187 | case R.id.iv_next:
188 | handleNextControl();
189 | break;
190 | }
191 | }
192 |
193 | private void handleNextControl() {
194 | MusicController.playNext();
195 | }
196 |
197 | public void updateNextMusic() {
198 | LocalMusicInfo musicInfo = MusicUtil.getInstance().getNextMusicInfo();
199 | updateCurMusic(musicInfo);
200 | }
201 |
202 | private void handlePreControl() {
203 | MusicController.playPre();
204 | }
205 |
206 | public void updatePreMusic() {
207 | LocalMusicInfo musicInfo = MusicUtil.getInstance().getPreMusicInfo();
208 | updateCurMusic(musicInfo);
209 | }
210 |
211 | private void updateCurMusic(LocalMusicInfo musicInfo) {
212 | updateMusicInfo(musicInfo);
213 | notifyListViewDataChange(musicInfo);
214 | MusicUtil.getInstance().setCurrPlayMusicInfo(musicInfo);
215 | }
216 |
217 | private void handleMusicControl() {
218 | switch (MusicPlayService.musicPlayService.curPlayState) {
219 | case PLAY_STATE_PLAYING:
220 | MusicController.pausePlay();
221 | break;
222 | case PLAY_STATE_PAUSED:
223 | MusicController.continuePlay();
224 | break;
225 | case PLAT_STATE_NORAML:
226 | if (MusicUtil.getInstance().getPlayMusicList().size() > 0) {
227 | updateCurMusic(MusicUtil.getInstance().getPlayMusicList().get(0));
228 | startPlay(MusicUtil.getInstance().getPlayMusicList().get(0));
229 | } else {
230 | Toast.makeText(this, "暂无可播放歌曲", Toast.LENGTH_SHORT);
231 | }
232 | break;
233 | }
234 | }
235 |
236 | private void resetAndStartPlay(LocalMusicInfo musicInfo) {
237 | MusicController.resetStartPlay(musicInfo.getSource());
238 | }
239 |
240 | private void startPlay(LocalMusicInfo musicInfo) {
241 | MusicController.startPlay(musicInfo.getSource());
242 | }
243 | }
244 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/MusicPlayService.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.media.AudioManager;
6 | import android.media.MediaPlayer;
7 | import android.os.Handler;
8 | import android.os.IBinder;
9 |
10 | import com.clearlee.lockscreenmusiccontrol.constant.MusicConstants;
11 | import com.clearlee.lockscreenmusiccontrol.mediasession.MediaSessionManager;
12 | import com.clearlee.lockscreenmusiccontrol.util.LogTool;
13 | import com.clearlee.lockscreenmusiccontrol.util.MusicUtil;
14 |
15 | public class MusicPlayService extends Service {
16 |
17 | public static MediaPlayer mMediaPlyer;
18 | public static MusicPlayService musicPlayService;
19 |
20 | public int curPlayState = PLAT_STATE_NORAML; //播放状态
21 | public static final int PLAT_STATE_NORAML = 0;
22 | public static final int PLAY_STATE_PLAYING = 1;
23 | public static final int PLAY_STATE_PAUSED = 2;
24 |
25 | private boolean resetMusic;
26 |
27 | private Handler refreshTimeHandler = new Handler();
28 |
29 | private MediaSessionManager mediaSessionManager;
30 |
31 | @Override
32 | public IBinder onBind(Intent intent) {
33 | return null;
34 | }
35 |
36 | @Override
37 | public void onCreate() {
38 | super.onCreate();
39 | musicPlayService = this;
40 | mediaSessionManager = new MediaSessionManager(this);
41 | initMediaPlayer();
42 | }
43 |
44 |
45 | private void initMediaPlayer() {
46 | LogTool.s("initMediaPlayer");
47 | resetMusic = false;
48 | curPlayState = PLAT_STATE_NORAML;
49 | mMediaPlyer = new MediaPlayer();
50 | mMediaPlyer.setAudioStreamType(AudioManager.STREAM_MUSIC);
51 | mMediaPlyer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
52 | @Override
53 | public void onCompletion(MediaPlayer mp) {
54 | LogTool.s("onCompletion");
55 | handleNextPlay();
56 | }
57 | });
58 | mMediaPlyer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
59 | @Override
60 | public void onPrepared(MediaPlayer mp) {
61 | realStartPlay();
62 | }
63 | });
64 | }
65 |
66 | @Override
67 | public int onStartCommand(Intent intent, int flags, int startId) {
68 | handleIntent(intent);
69 | return super.onStartCommand(intent, flags, startId);
70 | }
71 |
72 | private void startPlay() {
73 | LogTool.s("startPlay");
74 | try {
75 | if (mMediaPlyer != null) {
76 | mMediaPlyer.setDataSource(MusicUtil.getInstance().getCurrPlayMusicInfo().getSource());
77 | mMediaPlyer.prepareAsync();
78 | }
79 | } catch (Exception e) {
80 | LogTool.ex(e);
81 | }
82 | }
83 |
84 | private void handleIntent(Intent intent) {
85 |
86 | if (intent == null || intent.getAction() == null) {
87 | return;
88 | }
89 |
90 | switch (intent.getAction()) {
91 | case MusicConstants.MUSIC_ACTICON_START_PLAY:
92 | handleStartPlay();
93 | break;
94 | case MusicConstants.MUSIC_ACTICON_PAUSE_PLAY:
95 | handlePausePlay();
96 | break;
97 | case MusicConstants.MUSIC_ACTICON_CONTINUE_PLAY:
98 | handleStartPlay();
99 | break;
100 | case MusicConstants.MUSIC_ACTICON_RESET_START_PLAY:
101 | handleResetAndStartPlay();
102 | break;
103 | case MusicConstants.MUSIC_ACTICON_PLAY_PRE:
104 | handlePrePlay();
105 | break;
106 | case MusicConstants.MUSIC_ACTICON_PLAY_NEXT:
107 | handleNextPlay();
108 | break;
109 | }
110 | }
111 |
112 | public void handleNextPlay() {
113 | LogTool.s("handleNextPlay");
114 | try {
115 | if (App.getApp().activity != null) {
116 | App.getApp().activity.updateNextMusic();
117 | }
118 | resetMusic = true;
119 | curPlayState = PLAT_STATE_NORAML;
120 | handleStartPlay();
121 | } catch (Exception e) {
122 | LogTool.ex(e);
123 | }
124 | }
125 |
126 | public void handlePrePlay() {
127 | LogTool.s("handlePrePlay");
128 | try {
129 | if (App.getApp().activity != null) {
130 | App.getApp().activity.updatePreMusic();
131 | }
132 | resetMusic = true;
133 | curPlayState = PLAT_STATE_NORAML;
134 | handleStartPlay();
135 | } catch (Exception e) {
136 | LogTool.ex(e);
137 | }
138 | }
139 |
140 | public void handleResetAndStartPlay() {
141 | LogTool.s("handleResetAndStartPlay");
142 | try {
143 | resetMusic = true;
144 | curPlayState = PLAT_STATE_NORAML;
145 | handleStartPlay();
146 | } catch (Exception e) {
147 | LogTool.ex(e);
148 | }
149 | }
150 |
151 | private void resetStartPlay() {
152 | LogTool.s("resetStartPlay");
153 | try {
154 | if (mMediaPlyer != null) {
155 | mMediaPlyer.reset();
156 | initMediaPlayer();
157 | startPlay();
158 | }
159 | } catch (Exception e) {
160 | LogTool.ex(e);
161 | }
162 | }
163 |
164 |
165 | private void realStartPlay() {
166 | LogTool.s("realStartPlay");
167 | try {
168 | mMediaPlyer.start();
169 | mMediaPlyer.setVolume(1, 1);
170 | curPlayState = PLAY_STATE_PLAYING;
171 | refreshTimeTask();
172 | mediaSessionManager.updatePlaybackState(curPlayState);
173 | mediaSessionManager.updateLocMsg();
174 | } catch (Exception e) {
175 | LogTool.ex(e);
176 | }
177 | }
178 |
179 |
180 | public void handleStartPlay() {
181 | LogTool.s("handleStartPlay");
182 | try {
183 | App.getApp().activity.updateImage();
184 | switch (curPlayState) {
185 | case PLAT_STATE_NORAML: {
186 | if (resetMusic) {
187 | resetStartPlay();
188 | } else {
189 | startPlay();
190 | }
191 | resetMusic = false;
192 | }
193 | break;
194 | case PLAY_STATE_PAUSED:
195 | continuePlay();
196 | break;
197 | }
198 | } catch (Exception e) {
199 | LogTool.ex(e);
200 | }
201 | }
202 |
203 |
204 | public void handlePausePlay() {
205 | LogTool.s("handlePausePlay");
206 | try {
207 | if (curPlayState == PLAY_STATE_PLAYING && mMediaPlyer != null) {
208 | App.getApp().activity.updateImage();
209 | mMediaPlyer.pause();
210 | curPlayState = PLAY_STATE_PAUSED;
211 | mediaSessionManager.updatePlaybackState(curPlayState);
212 | }
213 | } catch (Exception e) {
214 | LogTool.ex(e);
215 | }
216 | }
217 |
218 | private void continuePlay() {
219 | LogTool.s("continuePlay");
220 | try {
221 | if (curPlayState == PLAY_STATE_PAUSED && mMediaPlyer != null) {
222 | realStartPlay();
223 | }
224 | } catch (Exception e) {
225 | LogTool.ex(e);
226 | }
227 | }
228 |
229 | private void refreshTimeTask() {
230 | LogTool.s("refreshTimeTask");
231 | try {
232 | refreshTimeHandler.postDelayed(new Runnable() {
233 | @Override
234 | public void run() {
235 | if (curPlayState == PLAY_STATE_PLAYING) {
236 | int position = mMediaPlyer.getCurrentPosition();
237 | if (App.getApp().activity != null) {
238 | App.getApp().activity.refreshTime(position);
239 | }
240 | refreshTimeHandler.postDelayed(this, 1000);
241 | }
242 | }
243 | }, 1000);
244 | } catch (Exception e) {
245 | LogTool.ex(e);
246 | }
247 | }
248 |
249 | @Override
250 | public void onDestroy() {
251 | super.onDestroy();
252 | if (mMediaPlyer != null) {
253 | mMediaPlyer.release();
254 | mMediaPlyer = null;
255 | }
256 | refreshTimeHandler = null;
257 | mediaSessionManager.release();
258 | }
259 | }
260 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/adapter/MusicAdapter.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.RelativeLayout;
10 | import android.widget.TextView;
11 |
12 | import com.clearlee.lockscreenmusiccontrol.R;
13 | import com.clearlee.lockscreenmusiccontrol.bean.LocalMusicInfo;
14 | import com.clearlee.lockscreenmusiccontrol.util.Common;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * Created by Clearlee on 2017/12/26 0026.
20 | */
21 |
22 | public class MusicAdapter extends BaseAdapter {
23 |
24 | private Context mContext;
25 | private List mDatas;
26 |
27 | public MusicAdapter(Context context, List data) {
28 | this.mContext = context;
29 | this.mDatas = data;
30 | }
31 |
32 |
33 | @Override
34 | public int getCount() {
35 | return mDatas.size();
36 | }
37 |
38 | @Override
39 | public Object getItem(int position) {
40 | return mDatas.get(position);
41 | }
42 |
43 | @Override
44 | public long getItemId(int position) {
45 | return position;
46 | }
47 |
48 | @Override
49 | public View getView(int position, View convertView, ViewGroup parent) {
50 |
51 | LocalMusicInfo musicInfo = mDatas.get(position);
52 |
53 | ViewHolder holder;
54 | if (convertView == null) {
55 | convertView = LayoutInflater.from(mContext).inflate(R.layout.item_music_list, null);
56 | holder = new ViewHolder(convertView);
57 | convertView.setTag(holder);
58 | } else {
59 | holder = (ViewHolder) convertView.getTag();
60 | }
61 |
62 | holder.tv_name.setText(musicInfo.getName() + "");
63 | holder.tv_author.setText(musicInfo.getAuthor() + "");
64 | holder.tv_duration.setText(Common.getSecDuration2HMSFormatString((int) musicInfo.getDuration() / 1000));
65 |
66 | if (musicInfo.isSelectedInShouye()) {
67 | holder.musicItem.setBackgroundColor(mContext.getResources().getColor(R.color.grayf0));
68 | } else {
69 | holder.musicItem.setBackgroundColor(mContext.getResources().getColor(R.color.white));
70 | }
71 |
72 | return convertView;
73 | }
74 |
75 | public class ViewHolder {
76 | TextView tv_name;
77 | TextView tv_author;
78 | ImageView iv_resource;
79 | TextView tv_duration;
80 | RelativeLayout musicItem;
81 |
82 | ViewHolder(View convertView) {
83 | tv_duration = (TextView) convertView.findViewById(R.id.tv_duration);
84 | tv_name = (TextView) convertView.findViewById(R.id.tv_name);
85 | tv_author = (TextView) convertView.findViewById(R.id.tv_author);
86 | iv_resource = (ImageView) convertView.findViewById(R.id.iv_resource);
87 | musicItem = (RelativeLayout) convertView.findViewById(R.id.music_item);
88 | }
89 |
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/bean/LocalMusicInfo.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.bean;
2 |
3 | /**
4 | * 本地音乐信息
5 | */
6 | public class LocalMusicInfo {
7 |
8 | private boolean isSelectedInShouye = false;//首页列表里是否已经选中
9 |
10 | String id = "";
11 | private String name = ""; //音乐名称
12 | private String author = ""; //音乐作者
13 | private String album = ""; //音乐专辑
14 | private long duration = 0; //音乐时长
15 | private long size = 0; //音乐大小
16 | private String source = ""; //音乐地址
17 |
18 | public String getId() {
19 | return id;
20 | }
21 |
22 | public void setId(String id) {
23 | this.id = id;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getAuthor() {
35 | return author;
36 | }
37 |
38 | public void setAuthor(String author) {
39 | this.author = author;
40 | }
41 |
42 | public long getDuration() {
43 | return duration;
44 | }
45 |
46 | public void setDuration(long duration) {
47 | this.duration = duration;
48 | }
49 |
50 | public String getSource() {
51 | return source;
52 | }
53 |
54 | public void setSource(String source) {
55 | this.source = source;
56 | }
57 |
58 | public long getSize() {
59 | return size;
60 | }
61 |
62 | public void setSize(long size) {
63 | this.size = size;
64 | }
65 |
66 | public String getAlbum() {
67 | return album;
68 | }
69 |
70 | public void setAlbum(String album) {
71 | this.album = album;
72 | }
73 |
74 | public boolean isSelectedInShouye() {
75 | return isSelectedInShouye;
76 | }
77 |
78 | public void setSelectedInShouye(boolean selectedInShouye) {
79 | isSelectedInShouye = selectedInShouye;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/constant/MusicConstants.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.constant;
2 |
3 | /**
4 | * Created by ZerdoorPHPDC on 2017/12/28 0028.
5 | */
6 |
7 | public class MusicConstants {
8 |
9 | public static final String PARAM_MUSIC_PATH = "PARAM_MUSIC_PATH";
10 |
11 | public static final String MUSIC_ACTICON_START_PLAY = "MUSIC_ACTICON_START_PLAY";
12 | public static final String MUSIC_ACTICON_RESET_START_PLAY = "MUSIC_ACTICON_RESET_START_PLAY";
13 | public static final String MUSIC_ACTICON_CONTINUE_PLAY = "MUSIC_ACTICON_CONTINUE_PLAY";
14 | public static final String MUSIC_ACTICON_PAUSE_PLAY = "MUSIC_ACTICON_PAUSE_PLAY";
15 |
16 | public static final String MUSIC_ACTICON_PLAY_NEXT = "MUSIC_ACTICON_PLAY_NEXT";
17 | public static final String MUSIC_ACTICON_PLAY_PRE = "MUSIC_ACTICON_PLAY_PRE";
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/controller/MusicController.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.controller;
2 |
3 | import android.content.Intent;
4 |
5 | import com.clearlee.lockscreenmusiccontrol.App;
6 | import com.clearlee.lockscreenmusiccontrol.MusicPlayService;
7 | import com.clearlee.lockscreenmusiccontrol.constant.MusicConstants;
8 |
9 | /**
10 | * Created by Clearlee on 2017/12/27 0027.
11 | */
12 |
13 | public class MusicController {
14 |
15 | public static void initMusicService() {
16 | sendCommandToService(null, null, null);
17 | }
18 |
19 | public static void startPlay(String path) {
20 | sendCommandToService(MusicConstants.MUSIC_ACTICON_START_PLAY, MusicConstants.PARAM_MUSIC_PATH, path);
21 | }
22 |
23 | public static void pausePlay() {
24 | sendCommandToService(MusicConstants.MUSIC_ACTICON_PAUSE_PLAY, null, null);
25 | }
26 |
27 | public static void continuePlay() {
28 | sendCommandToService(MusicConstants.MUSIC_ACTICON_CONTINUE_PLAY, null, null);
29 | }
30 |
31 | public static void resetStartPlay(String path) {
32 | sendCommandToService(MusicConstants.MUSIC_ACTICON_RESET_START_PLAY, MusicConstants.PARAM_MUSIC_PATH, path);
33 | }
34 |
35 | public static void playNext() {
36 | sendCommandToService(MusicConstants.MUSIC_ACTICON_PLAY_NEXT, null, null);
37 | }
38 |
39 | public static void playPre() {
40 | sendCommandToService(MusicConstants.MUSIC_ACTICON_PLAY_PRE, null, null);
41 | }
42 |
43 | //发送指令到音乐服务
44 | private static void sendCommandToService(String action, String param, String data) {
45 | Intent intent = new Intent();
46 | intent.setClass(App.getApp(), MusicPlayService.class);
47 | intent.setAction(action);
48 | if (param != null) {
49 | intent.putExtra(param, data);
50 | }
51 | App.getApp().startService(intent);
52 | }
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/mediasession/MediaSessionManager.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.mediasession;
2 |
3 | import android.support.v4.media.MediaMetadataCompat;
4 | import android.support.v4.media.session.MediaSessionCompat;
5 | import android.support.v4.media.session.PlaybackStateCompat;
6 |
7 | import com.clearlee.lockscreenmusiccontrol.MusicPlayService;
8 | import com.clearlee.lockscreenmusiccontrol.util.LogTool;
9 | import com.clearlee.lockscreenmusiccontrol.util.MusicUtil;
10 |
11 | /**
12 | * Created by Clearlee on 2018/1/4 0004.
13 | */
14 |
15 | public class MediaSessionManager {
16 |
17 | private static final String MY_MEDIA_ROOT_ID = "MediaSessionManager";
18 |
19 | private MusicPlayService musicPlayService;
20 | private MediaSessionCompat mMediaSession;
21 | private PlaybackStateCompat.Builder stateBuilder;
22 |
23 | public MediaSessionManager(MusicPlayService service) {
24 | this.musicPlayService = service;
25 | initSession();
26 | }
27 |
28 | public void initSession() {
29 | try {
30 | mMediaSession = new MediaSessionCompat(musicPlayService, MY_MEDIA_ROOT_ID);
31 | mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
32 | stateBuilder = new PlaybackStateCompat.Builder()
33 | .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_PAUSE
34 | | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS);
35 | mMediaSession.setPlaybackState(stateBuilder.build());
36 | mMediaSession.setCallback(sessionCb);
37 | mMediaSession.setActive(true);
38 | } catch (Exception e) {
39 | LogTool.ex(e);
40 | }
41 | }
42 |
43 | public void updatePlaybackState(int currentState) {
44 | int state = (currentState == MusicPlayService.PLAY_STATE_PAUSED) ? PlaybackStateCompat.STATE_PAUSED : PlaybackStateCompat.STATE_PLAYING;
45 | stateBuilder.setState(state, musicPlayService.mMediaPlyer.getCurrentPosition(), 1.0f);
46 | mMediaSession.setPlaybackState(stateBuilder.build());
47 | }
48 |
49 | public void updateLocMsg() {
50 | try {
51 | //同步歌曲信息
52 | MediaMetadataCompat.Builder md = new MediaMetadataCompat.Builder();
53 | md.putString(MediaMetadataCompat.METADATA_KEY_TITLE, MusicUtil.getInstance().getCurrPlayMusicInfo().getName());
54 | md.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, MusicUtil.getInstance().getCurrPlayMusicInfo().getAuthor());
55 | md.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, MusicUtil.getInstance().getCurrPlayMusicInfo().getAlbum());
56 | md.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, MusicUtil.getInstance().getCurrPlayMusicInfo().getDuration());
57 | mMediaSession.setMetadata(md.build());
58 | } catch (Exception e) {
59 | LogTool.ex(e);
60 | }
61 |
62 | }
63 |
64 | private MediaSessionCompat.Callback sessionCb = new MediaSessionCompat.Callback() {
65 | @Override
66 | public void onPlay() {
67 | super.onPlay();
68 | musicPlayService.handleStartPlay();
69 | }
70 |
71 | @Override
72 | public void onPause() {
73 | super.onPause();
74 | musicPlayService.handlePausePlay();
75 | }
76 |
77 | @Override
78 | public void onSkipToNext() {
79 | super.onSkipToNext();
80 | musicPlayService.handleNextPlay();
81 | }
82 |
83 | @Override
84 | public void onSkipToPrevious() {
85 | super.onSkipToPrevious();
86 | musicPlayService.handlePrePlay();
87 | }
88 |
89 | };
90 |
91 | public void release() {
92 | mMediaSession.setCallback(null);
93 | mMediaSession.setActive(false);
94 | mMediaSession.release();
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/util/Common.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.util;
2 |
3 | /**
4 | * Created by ZerdoorPHPDC on 2017/12/26 0026.
5 | */
6 |
7 | public class Common {
8 |
9 | //获取秒为单位的时长转成以时分秒显示的字符串
10 | public static String getSecDuration2HMSFormatString(int time) {
11 | String timeStr = null;
12 | int hour = 0;
13 | int minute = 0;
14 | int second = 0;
15 | if (time <= 0)
16 | return "00:00";
17 | else {
18 | minute = time / 60;
19 | if (minute < 60) {
20 | second = time % 60;
21 | timeStr = getDoubleDigitLeftFillZeroString(minute) + ":" + getDoubleDigitLeftFillZeroString(second);
22 | } else {
23 | hour = minute / 60;
24 | if (hour > 99)
25 | return "99:59:59";
26 | minute = minute % 60;
27 | second = time - hour * 3600 - minute * 60;
28 | if (hour > 0) {
29 | timeStr = getDoubleDigitLeftFillZeroString(hour) + ":" + getDoubleDigitLeftFillZeroString(minute) + ":" + getDoubleDigitLeftFillZeroString(second);
30 | } else {
31 | timeStr = getDoubleDigitLeftFillZeroString(minute) + ":" + getDoubleDigitLeftFillZeroString(second);
32 | }
33 | }
34 | }
35 | return timeStr;
36 | }
37 |
38 | //获取两位数格式的数字,未满10左边补0后的字符串
39 | public static String getDoubleDigitLeftFillZeroString(int i) {
40 | if (i >= 0 && i < 10)
41 | return "0" + Integer.toString(i);
42 | else
43 | return "" + i;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/util/LogTool.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.util;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.PrintWriter;
6 | import java.io.StringWriter;
7 |
8 | /**
9 | * **
10 | * 用来打印日志的
11 | *
12 | * @author Administrator
13 | */
14 | public class LogTool {
15 | static String tag = "mylog";
16 | /**
17 | * **
18 | * 打印一个对象
19 | *
20 | * @param
21 | */
22 | public static void p(Object s) {
23 | try {
24 | Log.e(tag, s.toString());
25 | } catch (Exception e) {
26 | } catch (Error error) {
27 | }
28 | }
29 |
30 | /**
31 | * **
32 | * 控制台打印一个对象
33 | *
34 | * @param obj
35 | */
36 | public static void s(Object obj) {
37 | try {
38 | Log.v(tag, ""+obj);
39 | }catch (Exception e){}
40 | }
41 |
42 | /**
43 | * **
44 | * 打印一个异常
45 | *
46 | * @param
47 | */
48 | public static void ex(Throwable e) {
49 | StringWriter writer = new StringWriter();
50 | PrintWriter printWriter = new PrintWriter(writer);
51 | e.printStackTrace(printWriter);
52 | try{
53 | Log.e(tag, writer.toString());
54 | }catch (Exception e2){}
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/util/MusicUtil.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.util;
2 |
3 | import android.database.Cursor;
4 | import android.net.Uri;
5 | import android.provider.MediaStore;
6 | import android.support.v4.media.session.MediaControllerCompat;
7 |
8 | import com.clearlee.lockscreenmusiccontrol.App;
9 | import com.clearlee.lockscreenmusiccontrol.bean.LocalMusicInfo;
10 |
11 | import java.util.ArrayList;
12 | import java.util.HashSet;
13 | import java.util.List;
14 |
15 | /**
16 | * Created by Clearlee on 2017/12/26 0026.
17 | */
18 |
19 | public class MusicUtil {
20 |
21 | private List localMusicList = new ArrayList<>();
22 | private MediaControllerCompat mMediaController;
23 | private Uri contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;//Uri,指向external的database
24 | private LocalMusicInfo curPlayMusicInfo;
25 |
26 | //projection:选择的列; where:过滤条件; sortOrder:排序。
27 | private String[] projection = {
28 | MediaStore.Audio.Media._ID,
29 | MediaStore.Audio.Media.DISPLAY_NAME,
30 | MediaStore.Audio.Media.TITLE,
31 | MediaStore.Audio.Media.DATA,
32 | MediaStore.Audio.Media.ALBUM,
33 | MediaStore.Audio.Media.ARTIST,
34 | MediaStore.Audio.Media.DURATION,
35 | MediaStore.Audio.Media.SIZE
36 | };
37 |
38 | private static MusicUtil musicUtil;
39 |
40 | public static MusicUtil getInstance() {
41 | if (musicUtil == null) {
42 | synchronized (MusicUtil.class) {
43 | if (musicUtil == null) {
44 | musicUtil = new MusicUtil();
45 | }
46 | }
47 | }
48 | return musicUtil;
49 | }
50 |
51 | public List getPlayMusicList() {
52 | return localMusicList;
53 | }
54 |
55 | public HashSet getLocalMusicData() {
56 | HashSet result = new HashSet<>();
57 | try {
58 | Cursor cursor = App.getApp().getContentResolver().query(contentUri, projection, null, null, MediaStore.Audio.Media.DATA);
59 | if (cursor == null) {
60 | LogTool.s("Music Loader cursor == null.");
61 | } else if (!cursor.moveToFirst()) {
62 | LogTool.s("Music Loader cursor.moveToFirst() returns false.");
63 | } else {
64 | int displayNameCol = cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME);
65 | int titleCol = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
66 | int albumCol = cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM);
67 | int idCol = cursor.getColumnIndex(MediaStore.Audio.Media._ID);
68 | int durationCol = cursor.getColumnIndex(MediaStore.Audio.Media.DURATION);
69 | int sizeCol = cursor.getColumnIndex(MediaStore.Audio.Media.SIZE);
70 | int artistCol = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
71 | int urlCol = cursor.getColumnIndex(MediaStore.Audio.Media.DATA);
72 |
73 | do {
74 | String displayName = cursor.getString(displayNameCol);
75 |
76 | String album = cursor.getString(albumCol);
77 |
78 | String title = cursor.getString(titleCol);
79 | long id = cursor.getLong(idCol);
80 | int duration = cursor.getInt(durationCol);
81 | long size = cursor.getLong(sizeCol);
82 | String artist = cursor.getString(artistCol);
83 | String url = cursor.getString(urlCol);
84 |
85 | if (url.replace(title, "").toLowerCase().contains("record"))
86 | continue;//如果这个音频文件的目录包含这个内容就被指认为录音文件过滤
87 | if (displayName.contains("录音") || title.contains("录音"))
88 | continue;//如果歌名含有录音两个字就当录音文件过滤
89 | if (displayName.contains("record") || title.contains("record"))
90 | continue;//如果歌名含有record就当录音文件过滤
91 | if (duration < 70 * 1000) continue;//过滤时长小于70秒的
92 |
93 | if (displayName.endsWith(".mp3") || displayName.endsWith(".wav") || displayName.endsWith(".m4a")) {
94 | LocalMusicInfo musicInfo = new LocalMusicInfo();
95 | musicInfo.setId(id + "");
96 | musicInfo.setName(title);
97 | musicInfo.setDuration(duration);
98 | musicInfo.setSize(size);
99 | musicInfo.setAuthor(artist);
100 | musicInfo.setAlbum(album);
101 | musicInfo.setSource(url);
102 |
103 | if (!result.contains(musicInfo)) {
104 | result.add(musicInfo);
105 | }
106 |
107 | }
108 | } while (cursor.moveToNext());
109 | }
110 | } catch (Exception e) {
111 | LogTool.ex(e);
112 | }
113 | return result;
114 | }
115 |
116 | public void setController(MediaControllerCompat controller) {
117 | this.mMediaController = controller;
118 | }
119 |
120 | public MediaControllerCompat getMediaContorller() {
121 | return mMediaController;
122 | }
123 |
124 |
125 | public void setCurrPlayMusicInfo(LocalMusicInfo musicInfo) {
126 | this.curPlayMusicInfo = musicInfo;
127 | }
128 |
129 | public LocalMusicInfo getCurrPlayMusicInfo() {
130 | return curPlayMusicInfo;
131 | }
132 |
133 |
134 | public LocalMusicInfo getPreMusicInfo() {
135 | int curIndex = getPlayMusicList().indexOf(getCurrPlayMusicInfo());
136 | int index = curIndex - 1;
137 | if (index < 0) {
138 | index = getPlayMusicList().size() - 1;
139 | }
140 | return getPlayMusicList().get(index);
141 | }
142 |
143 | public LocalMusicInfo getNextMusicInfo() {
144 | int curIndex = getPlayMusicList().indexOf(getCurrPlayMusicInfo());
145 | int index = curIndex + 1;
146 | if (index > getPlayMusicList().size() - 1) {
147 | index = 0;
148 | }
149 | return getPlayMusicList().get(index);
150 | }
151 |
152 | }
153 |
--------------------------------------------------------------------------------
/app/src/main/java/com/clearlee/lockscreenmusiccontrol/util/ThreadManager.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol.util;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 |
6 | /**
7 | * Created by Clearlee on 2017/12/26 0026.
8 | */
9 |
10 | public class ThreadManager {
11 | static ExecutorService mExecutorService;
12 |
13 | public static ExecutorService getExecutorService() {
14 |
15 | if (mExecutorService == null) {
16 | mExecutorService = Executors.newCachedThreadPool();
17 | }
18 |
19 | return mExecutorService;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_white_yuanjiao.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/music_progressbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
27 |
28 |
29 |
39 |
40 |
48 |
49 |
55 |
56 |
68 |
69 |
79 |
80 |
95 |
96 |
105 |
106 |
115 |
116 |
117 |
126 |
127 |
134 |
135 |
136 |
137 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_music_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
25 |
31 |
40 |
41 |
42 |
53 |
54 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/currplay_music_qq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/currplay_music_qq.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/music_button_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/music_button_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/music_button_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/music_button_play.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/music_local.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/music_local.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/next_music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/next_music.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/pre_music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxhdpi/pre_music.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ffffff
7 | #c0c0c0
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LockScreenMusicControl
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/clearlee/lockscreenmusiccontrol/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.clearlee.lockscreenmusiccontrol;
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 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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/Clearlee/LockScreenMusicControl/327b0e4204fe47eb7f6356514523020cf6f5e846/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Dec 26 14:55:20 CST 2017
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-3.3-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 |
--------------------------------------------------------------------------------