├── .idea
├── .name
├── vcs.xml
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
├── jarRepositories.xml
└── codeStyles
│ └── Project.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── preloaded_fonts.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── font_certs.xml
│ │ │ ├── drawable
│ │ │ │ ├── pause.png
│ │ │ │ ├── play.png
│ │ │ │ ├── rphku7.jpg
│ │ │ │ ├── background.jpg
│ │ │ │ ├── download1.jpg
│ │ │ │ ├── songlistbackground.xml
│ │ │ │ ├── ic_fast.xml
│ │ │ │ ├── ic_backward.xml
│ │ │ │ ├── ic_music_note_black_24dp.xml
│ │ │ │ ├── ic_skip_next_black_24dp.xml
│ │ │ │ ├── ic_skip_previous_black_24dp.xml
│ │ │ │ ├── ic_baseline_play_arrow.xml
│ │ │ │ ├── item.xml
│ │ │ │ ├── ic_baseline_pause.xml
│ │ │ │ ├── ic_play_circle_filled_black_24dp.xml
│ │ │ │ ├── ic_pause_circle_filled_black_24dp.xml
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── font
│ │ │ │ ├── blackjack
│ │ │ │ │ ├── blackjack.otf
│ │ │ │ │ └── Typadelic License - Black Jack.txt
│ │ │ │ ├── sansation
│ │ │ │ │ ├── Sansation-Bold.ttf
│ │ │ │ │ ├── Sansation-Light.ttf
│ │ │ │ │ ├── Sansation-Italic.ttf
│ │ │ │ │ ├── Sansation-Regular.ttf
│ │ │ │ │ ├── Sansation-BoldItalic.ttf
│ │ │ │ │ ├── Sansation-LightItalic.ttf
│ │ │ │ │ └── SIL Open Font License.txt
│ │ │ │ ├── autour_one.xml
│ │ │ │ ├── metamorphous.xml
│ │ │ │ └── amaranth_bold_italic.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── rv_item.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_player.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── devs
│ │ │ │ └── musicplayer
│ │ │ │ ├── Playable.java
│ │ │ │ ├── Services
│ │ │ │ └── NotificationActionService.java
│ │ │ │ ├── BackgroundService.java
│ │ │ │ ├── OnClearFromRecentService.java
│ │ │ │ ├── Track.java
│ │ │ │ ├── SongsAdapter.java
│ │ │ │ ├── CreateNotification.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── PlayerActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── devs
│ │ │ └── musicplayer
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── devs
│ │ └── musicplayer
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── assets
├── readme1.jpg
└── readme2.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .github
└── workflows
│ └── action.yml
├── gradle.properties
├── README.md
├── .gitignore
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Music Player
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='Music Player'
2 | include ':app'
3 |
--------------------------------------------------------------------------------
/assets/readme1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/assets/readme1.jpg
--------------------------------------------------------------------------------
/assets/readme2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/assets/readme2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Music Player
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/drawable/pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/drawable/play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rphku7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/drawable/rphku7.jpg
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/drawable/background.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/download1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/drawable/download1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/font/blackjack/blackjack.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/blackjack/blackjack.otf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-Light.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-Italic.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-BoldItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/Sansation-LightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/font/sansation/Sansation-LightItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sijan8s3/MusicPlayer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3DDC84
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/Playable.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | public interface Playable {
4 | void onTrackPrevious();
5 | void onTrackPause();
6 | void onTrackPlay();
7 | void onTrackNext();
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/songlistbackground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Oct 05 12:34:41 IST 2020
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-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #35567D
4 | #222D3C
5 | #F8B195
6 | #FFFFFF
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @font/amaranth_bold_italic
5 | - @font/autour_one
6 | - @font/metamorphous
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_fast.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_backward.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_music_note_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_skip_next_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/font/autour_one.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_skip_previous_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/font/metamorphous.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_play_arrow.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_pause.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/font/amaranth_bold_italic.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_circle_filled_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pause_circle_filled_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/devs/musicplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/Services/NotificationActionService.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer.Services;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | public class NotificationActionService extends BroadcastReceiver {
8 | @Override
9 | public void onReceive(Context context, Intent intent) {
10 | context.sendBroadcast(new Intent("TRACKS_TRACKS").putExtra("actionname",intent.getAction()));
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/BackgroundService.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 |
7 | public class BackgroundService extends Service {
8 | private static final int NOTIF_ID = 1;
9 | private static final String NOTIFI_CHANNEL_ID = "Devs_Player";
10 |
11 | public BackgroundService() {}
12 |
13 | @Override
14 | public IBinder onBind(Intent intent) {
15 | // TODO: Return the communication channel to the service.
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.github/workflows/action.yml:
--------------------------------------------------------------------------------
1 | name: Format
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | formatting:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v2 # v2 minimum required
13 | - uses: actions/setup-java@v1
14 | with:
15 | # Recommended: latest versions of Google Java Format require JDK 11+
16 | java-version: "11"
17 | - uses: axel-op/googlejavaformat-action@v3
18 | with:
19 | args: "--skip-sorting-imports --replace"
20 | # Recommended if you use MacOS:
21 | # githubToken: ${{ secrets.GITHUB_TOKEN }}
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/rv_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/OnClearFromRecentService.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | public class OnClearFromRecentService extends Service {
10 | @Nullable
11 | @Override
12 | public IBinder onBind(Intent intent) {
13 | return null;
14 | }
15 |
16 | @Override
17 | public int onStartCommand(Intent intent, int flags, int startId) {
18 | return START_NOT_STICKY;
19 | }
20 |
21 | @Override
22 | public void onDestroy() {
23 | super.onDestroy();
24 | }
25 |
26 | @Override
27 | public void onTaskRemoved(Intent rootIntent) {
28 | stopSelf();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/Track.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | public class Track {
4 | private String title;
5 | private String artist;
6 | private int image;
7 |
8 | public Track(String title, String artist, int image) {
9 | this.title = title;
10 | this.artist = artist;
11 | this.image = image;
12 | }
13 |
14 | public String getTitle() {
15 | return title;
16 | }
17 |
18 | public void setTitle(String title) {
19 | this.title = title;
20 | }
21 |
22 | public String getArtist() {
23 | return artist;
24 | }
25 |
26 | public void setArtist(String artist) {
27 | this.artist = artist;
28 | }
29 |
30 | public int getImage() {
31 | return image;
32 | }
33 |
34 | public void setImage(int image) {
35 | this.image = image;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/devs/musicplayer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.devs.musicplayer", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.devs.musicplayer"
9 | minSdkVersion 23
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 |
29 | implementation 'androidx.appcompat:appcompat:1.1.0'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 |
32 | implementation 'androidx.media:media:1.1.0'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
36 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
37 | implementation 'com.karumi:dexter:6.1.2'
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
🎧 MusicPlayer
2 |
3 |
4 | An amazing music player which will search your device and plays the song.
5 |
6 |
7 |
8 |
9 | [](https://github.com/sijan8s3/MusicPlayer/graphs/commit-activity)
10 | [](https://github.com/sijan8s3/MusicPlayer/issues/)
11 | [](https://github.com/sijan8s3/MusicPlayer/network/)
12 | [](https://github.com/sijan8s3/MusicPlayer/stargazers/)
13 |
14 |
15 |
16 | ## 😄 Contribuiting
17 | Checkout our [issues](https://github.com/sijan8s3/MusicPlayer/issues) page.
18 |
19 | ## 🎵 Features
20 | - Display all songs(files with audio extension) in a recyclerview.
21 | - Allows you to choose the music & plays it with android media player.
22 | - Can do previous, next, play, pause, volume up and down.
23 | - Capable to run in background.
24 |
25 | ## 📷 Screenshots
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Author: [Sijan Neupane](https://github.com/sijan8s3)
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/font/blackjack/Typadelic License - Black Jack.txt:
--------------------------------------------------------------------------------
1 | September 13, 2002
2 |
3 | You may use this font in any of your projects. If you use this font for a commercial project or design something really fantastic with it, drop me a line.
4 |
5 | DISCLAIMER:
6 |
7 | BLACK JACK works fine on my Macintosh. No guarantee of any kind is made this this will work on your machine. Typadelic makes no warranties, express or implied, regarding this font. Typadelic does not warrant, guarantee or make any represenations regarding the use or the results of the use of this font in terms of its reliability, or otherwise. In no event will Typadelic be liable for any consequential, incidental or indirect damages arising out of the use or inability to use BLACK JACK. (This notice must be included with any distribution).
8 |
9 | Please take a moment to mention where you found BLACK JACK and feel free to comment or criticize, care of "ronna@typadelic.com"
10 |
11 | BLACK JACK is free, but it is NOT in the public domain and remains the exclusive property of Typadelic.
12 |
13 | COPYRIGHT & DISTRIBUTION INFORMATION:
14 |
15 | BLACK JACK is copyright ©2002 Typadelic Fonts. All rights reserved.
16 |
17 | IMPORTANT: You may only distribute BLACK JACK WITH PRIOR WRITTEN PERMISSION FROM THE AUTHOR; after receiving said permission, YOU MUST INCLUDE THIS DOCUMENT. To sum up, this font may not be remixed or redistributed in any way (it may not be sold, distributed commercially, or made available for download) without permission.
18 |
19 | FOR PERMISSION TO DISTRIBUTE IN ANY WAY, SHAPE, OR FORM, WRITE TO THE FOLLOWING EMAIL ADDRESS:
20 |
21 | ronna@typadelic.com
22 |
23 | Other fonts, free or otherwise, available at or
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.aar
4 | *.ap_
5 | *.aab
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 | # Uncomment the following line in case you need and you don't have the release build type files in your app
18 | # release/
19 |
20 | # Gradle files
21 | .gradle/
22 | build/
23 |
24 | # Local configuration file (sdk path, etc)
25 | local.properties
26 |
27 | # Proguard folder generated by Eclipse
28 | proguard/
29 |
30 | # Log Files
31 | *.log
32 |
33 | # Android Studio Navigation editor temp files
34 | .navigation/
35 |
36 | # Android Studio captures folder
37 | captures/
38 |
39 | # IntelliJ
40 | *.iml
41 | .idea/workspace.xml
42 | .idea/tasks.xml
43 | .idea/gradle.xml
44 | .idea/assetWizardSettings.xml
45 | .idea/dictionaries
46 | .idea/libraries
47 | # Android Studio 3 in .gitignore file.
48 | .idea/caches
49 | .idea/modules.xml
50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
51 | .idea/navEditor.xml
52 |
53 | # Keystore files
54 | # Uncomment the following lines if you do not want to check your keystore files in.
55 | #*.jks
56 | #*.keystore
57 |
58 | # External native build folder generated in Android Studio 2.2 and later
59 | .externalNativeBuild
60 | .cxx/
61 |
62 | # Google Services (e.g. APIs or Firebase)
63 | # google-services.json
64 |
65 | # Freeline
66 | freeline.py
67 | freeline/
68 | freeline_project_description.json
69 |
70 | # fastlane
71 | fastlane/report.xml
72 | fastlane/Preview.html
73 | fastlane/screenshots
74 | fastlane/test_output
75 | fastlane/readme.md
76 |
77 | # Version control
78 | vcs.xml
79 |
80 | # lint
81 | lint/intermediates/
82 | lint/generated/
83 | lint/outputs/
84 | lint/tmp/
85 | # lint/reports/
86 |
87 | # Android Profiling
88 | *.hprof
89 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/SongsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
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.TextView;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.recyclerview.widget.RecyclerView;
11 |
12 | class SongsAdapter extends RecyclerView.Adapter {
13 |
14 | String[] songNames;
15 | Context mContext;
16 |
17 | OnSongClickListener onSongClickListener;
18 |
19 | public SongsAdapter(String[] songNames, Context context) {
20 | this.songNames = songNames;
21 | mContext = context;
22 | }
23 |
24 | public void setOnSongClickListener(OnSongClickListener onSongClickListener) {
25 | this.onSongClickListener = onSongClickListener;
26 | }
27 |
28 | @NonNull
29 | @Override
30 | public SongsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
31 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item, parent, false);
32 | return new SongsViewHolder(view, onSongClickListener);
33 | }
34 |
35 | @Override
36 | public void onBindViewHolder(@NonNull SongsViewHolder holder, int position) {
37 | holder.song_tv.setText(songNames[position]);
38 | }
39 |
40 | @Override
41 | public int getItemCount() {
42 | return songNames.length;
43 | }
44 |
45 | public interface OnSongClickListener {
46 | void onSongClick(int position);
47 | }
48 |
49 | public static class SongsViewHolder extends RecyclerView.ViewHolder {
50 | TextView song_tv;
51 |
52 | public SongsViewHolder(@NonNull View itemView, final OnSongClickListener onSongClickListener) {
53 | super(itemView);
54 | song_tv = itemView.findViewById(R.id.song_tv);
55 |
56 | song_tv.setOnClickListener(
57 | new View.OnClickListener() {
58 | @Override
59 | public void onClick(View view) {
60 | if (onSongClickListener != null) {
61 | int position = getAdapterPosition();
62 | if (position != RecyclerView.NO_POSITION) {
63 | onSongClickListener.onSongClick(position);
64 | }
65 | }
66 | }
67 | });
68 | }
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @array/com_google_android_gms_fonts_certs_dev
5 | - @array/com_google_android_gms_fonts_certs_prod
6 |
7 |
8 | -
9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs=
10 |
11 |
12 |
13 | -
14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/CreateNotification.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.graphics.Bitmap;
9 | import android.graphics.BitmapFactory;
10 | import android.os.Build;
11 | import android.support.v4.media.session.MediaSessionCompat;
12 |
13 | import androidx.core.app.NotificationCompat;
14 | import androidx.core.app.NotificationManagerCompat;
15 |
16 | import com.devs.musicplayer.Services.NotificationActionService;
17 |
18 | public class CreateNotification {
19 | public static final String CHANNEL_ID = "channel1";
20 | public static final String ACTION_PREVIOUS = "actionprevious";
21 | public static final String ACTION_PLAY = "actionplay";
22 | public static final String ACTION_NEXT = "actionnext";
23 |
24 | public static Notification notification;
25 |
26 | public static void createNotification(Context context, String songsToSend, int playButton, int pos, int size){
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
28 | NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
29 |
30 |
31 | MediaSessionCompat mediaSessionCompat = new MediaSessionCompat(context,"tag");
32 | Bitmap icon = BitmapFactory.decodeResource(context.getResources(),R.drawable.background);
33 |
34 | PendingIntent pendingIntentPrevious;
35 | int drw_previous;
36 | if (pos == 0){
37 | pendingIntentPrevious = null;
38 | drw_previous =0;
39 | }else {
40 | Intent intentPrevious = new Intent(context, NotificationActionService.class).setAction(ACTION_PREVIOUS);
41 |
42 | pendingIntentPrevious = PendingIntent.getBroadcast(context,0,intentPrevious,PendingIntent.FLAG_UPDATE_CURRENT);
43 | drw_previous = R.drawable.ic_skip_previous_black_24dp;
44 | }
45 | Intent intentPlay = new Intent(context, NotificationActionService.class).setAction(ACTION_PLAY);
46 |
47 | PendingIntent pendingIntentPlay = PendingIntent.getBroadcast(context,0,intentPlay,PendingIntent.FLAG_UPDATE_CURRENT);
48 |
49 | PendingIntent pendingIntentNext;
50 | int drw_next;
51 | if (pos == size){
52 | pendingIntentNext = null;
53 | drw_next =0;
54 | }else {
55 | Intent intentNext = new Intent(context, NotificationActionService.class).setAction(ACTION_NEXT);
56 |
57 | pendingIntentNext = PendingIntent.getBroadcast(context,0,intentNext,PendingIntent.FLAG_UPDATE_CURRENT);
58 | drw_next = R.drawable.ic_skip_next_black_24dp;
59 | }
60 |
61 | //create notification
62 | notification = new NotificationCompat.Builder(context,CHANNEL_ID)
63 | .setSmallIcon(R.drawable.ic_music_note_black_24dp)
64 | .setContentTitle(songsToSend)
65 | .setContentText("Artist")
66 | .setLargeIcon(icon)
67 | .setOnlyAlertOnce(true)
68 | .setShowWhen(false)
69 | .addAction(drw_previous,"Previous",pendingIntentPrevious)
70 | .addAction(playButton,"Play",pendingIntentPlay)
71 | .addAction(drw_next,"Next",pendingIntentNext)
72 | .setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
73 | .setShowActionsInCompactView(0, 1, 2)
74 | .setMediaSession(mediaSessionCompat.getSessionToken()))
75 | .setPriority(NotificationCompat.PRIORITY_LOW)
76 | .build();
77 | notificationManagerCompat.notify(1,notification);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | xmlns:android
23 |
24 | ^$
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | xmlns:.*
34 |
35 | ^$
36 |
37 |
38 | BY_NAME
39 |
40 |
41 |
42 |
43 |
44 |
45 | .*:id
46 |
47 | http://schemas.android.com/apk/res/android
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | .*:name
57 |
58 | http://schemas.android.com/apk/res/android
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | name
68 |
69 | ^$
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | style
79 |
80 | ^$
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | ^$
92 |
93 |
94 | BY_NAME
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | http://schemas.android.com/apk/res/android
104 |
105 |
106 | ANDROID_ATTRIBUTE_ORDER
107 |
108 |
109 |
110 |
111 |
112 |
113 | .*
114 |
115 | .*
116 |
117 |
118 | BY_NAME
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/app/src/main/res/font/sansation/SIL Open Font License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 by Bernd Montag (berndmontag@gmx.de), with Reserved Font Name 'Sansation'
2 |
3 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
4 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
5 |
6 | -----------------------------------------------------------
7 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
8 | -----------------------------------------------------------
9 |
10 | PREAMBLE
11 | The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
12 |
13 | The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
14 |
15 | DEFINITIONS
16 | "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
17 |
18 | "Reserved Font Name" refers to any names specified as such after the copyright statement(s).
19 |
20 | "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
21 |
22 | "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
23 |
24 | "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
25 |
26 | PERMISSION & CONDITIONS
27 | Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
28 |
29 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
30 |
31 | 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
32 |
33 | 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
34 |
35 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
36 |
37 | 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
38 |
39 | TERMINATION
40 | This license becomes null and void if any of the above conditions are not met.
41 |
42 | DISCLAIMER
43 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import android.Manifest;
8 | import android.app.NotificationChannel;
9 | import android.app.NotificationManager;
10 | import android.content.Intent;
11 | import android.os.Build;
12 | import android.os.Bundle;
13 | import android.os.Environment;
14 |
15 | import com.karumi.dexter.Dexter;
16 | import com.karumi.dexter.PermissionToken;
17 | import com.karumi.dexter.listener.PermissionDeniedResponse;
18 | import com.karumi.dexter.listener.PermissionGrantedResponse;
19 | import com.karumi.dexter.listener.PermissionRequest;
20 | import com.karumi.dexter.listener.single.PermissionListener;
21 |
22 | import java.io.File;
23 | import java.util.ArrayList;
24 |
25 | public class MainActivity extends AppCompatActivity {
26 |
27 | NotificationManager notificationManager;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 |
34 | runtimePermission();
35 | }
36 |
37 |
38 | // taking runtime permission for external storage
39 | public void runtimePermission() {
40 | Dexter.withContext(this)
41 | .withPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
42 | .withListener(
43 | new PermissionListener() {
44 | @Override
45 | public void onPermissionGranted(PermissionGrantedResponse permissionGrantedResponse) {
46 | display();
47 | }
48 |
49 | @Override
50 | public void onPermissionDenied(PermissionDeniedResponse permissionDeniedResponse) {
51 | }
52 |
53 | @Override
54 | public void onPermissionRationaleShouldBeShown(
55 | PermissionRequest permissionRequest, PermissionToken permissionToken) {
56 | permissionToken.continuePermissionRequest();
57 | }
58 | })
59 | .check();
60 | }
61 |
62 | // searching and adding files to the array
63 | public ArrayList findSong(File file) {
64 | ArrayList arrayList = new ArrayList<>();
65 |
66 | File[] files = file.listFiles();
67 | for (File singleFile : files) {
68 | if (singleFile.isDirectory() && !singleFile.isHidden()) {
69 | arrayList.addAll(findSong(singleFile));
70 | } else if ((singleFile.getName().endsWith(".mp3") || singleFile.getName().endsWith(".wav"))
71 | && !singleFile.getName().startsWith("._")) {
72 | arrayList.add(singleFile);
73 | }
74 | }
75 | return arrayList;
76 | }
77 |
78 | void display() {
79 | RecyclerView recyclerView = findViewById(R.id.music_rv);
80 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
81 |
82 | final ArrayList songs = findSong(Environment.getExternalStorageDirectory());
83 | final String[] songNames = new String[songs.size()];
84 |
85 | for (int i = 0; i < songs.size(); i++) {
86 | songNames[i] = songs.get(i).getName().toString().replace(".mp3", "").replace("wav", "");
87 | }
88 |
89 | SongsAdapter adapter = new SongsAdapter(songNames, this);
90 | recyclerView.setAdapter(adapter);
91 |
92 | adapter.setOnSongClickListener(
93 | new SongsAdapter.OnSongClickListener() {
94 | @Override
95 | public void onSongClick(int position) {
96 | ArrayList songsToSend = new ArrayList<>();
97 | startActivity(
98 | new Intent(getApplicationContext(), PlayerActivity.class)
99 | .putExtra("songs", songs)
100 | .putExtra("songName", songNames[position])
101 | .putExtra("pos", position));
102 |
103 | }
104 | });
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
27 |
28 |
29 |
48 |
49 |
69 |
70 |
85 |
86 |
99 |
100 |
113 |
114 |
129 |
130 |
143 |
144 |
157 |
158 |
171 |
172 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/app/src/main/java/com/devs/musicplayer/PlayerActivity.java:
--------------------------------------------------------------------------------
1 | package com.devs.musicplayer;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.annotation.SuppressLint;
7 | import android.app.NotificationChannel;
8 | import android.app.NotificationManager;
9 | import android.content.BroadcastReceiver;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.content.IntentFilter;
13 | import android.media.MediaPlayer;
14 | import android.net.Uri;
15 | import android.os.Build;
16 | import android.os.Bundle;
17 | import android.os.Handler;
18 | import android.os.Message;
19 | import android.view.MenuItem;
20 | import android.view.View;
21 | import android.widget.Button;
22 | import android.widget.SeekBar;
23 | import android.widget.TextView;
24 |
25 | import java.io.File;
26 | import java.util.ArrayList;
27 |
28 | public class PlayerActivity extends AppCompatActivity implements Playable {
29 | int position;
30 | TextView play;
31 | Button previous, next;
32 | SeekBar seekBar;
33 | TextView playerSongName;
34 | String songName;
35 | static MediaPlayer myMediaPlayer;
36 | File song;
37 | ArrayList songs;
38 | Thread updateSeekBar;
39 | TextView curTime, totTime;
40 | NotificationManager notificationManager;
41 | boolean isPlaying = false;
42 |
43 |
44 | @Override
45 | protected void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.activity_player);
48 |
49 | play = findViewById(R.id.play);
50 | previous = findViewById(R.id.previous);
51 | next = findViewById(R.id.next);
52 | playerSongName = findViewById(R.id.song_name);
53 | seekBar = findViewById(R.id.seekBar);
54 | curTime = findViewById(R.id.curTime);
55 | totTime = findViewById(R.id.totalTime);
56 |
57 | getSupportActionBar().setTitle("Now Playing");
58 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
59 | getSupportActionBar().setDisplayShowHomeEnabled(true);
60 |
61 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
62 | createChannel();
63 | registerReceiver(broadcastReceiver, new IntentFilter("TRACKS_TRACKS"));
64 | startService(new Intent(getBaseContext(),OnClearFromRecentService.class));
65 | }
66 |
67 | /* updateSeekBar= new Thread() {
68 | @Override
69 | public void run() {
70 |
71 | int totalDuration= myMediaPlayer.getDuration();
72 | int currentPosition=0;
73 |
74 | while (currentPosition= Build.VERSION_CODES.O){
237 | NotificationChannel channel = new NotificationChannel(CreateNotification.CHANNEL_ID,"Music", NotificationManager.IMPORTANCE_LOW);
238 |
239 | notificationManager = getSystemService(NotificationManager.class);
240 | if (notificationManager != null){
241 | notificationManager.createNotificationChannel(channel);
242 | }
243 | }
244 | }
245 |
246 | @Override
247 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
248 | if (item.getItemId() == android.R.id.home) {
249 | onBackPressed();
250 | }
251 | return super.onOptionsItemSelected(item);
252 | }
253 |
254 | public String createTimeLabel(int duration) {
255 | String timeLabel = "";
256 | int min = duration / 1000 / 60;
257 | int sec = duration / 1000 % 60;
258 |
259 | timeLabel += min + ":";
260 | if (sec < 10) timeLabel += "0";
261 | timeLabel += sec;
262 |
263 | return timeLabel;
264 | }
265 |
266 | @SuppressLint("HandlerLeak")
267 | private Handler handler =
268 | new Handler() {
269 | @Override
270 | public void handleMessage(Message msg) {
271 | // Log.i("handler ", "handler called");
272 | int current_position = msg.what;
273 | seekBar.setProgress(current_position);
274 | String cTime = createTimeLabel(current_position);
275 | curTime.setText(cTime);
276 | }
277 | };
278 | BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
279 | @Override
280 | public void onReceive(Context context, Intent intent) {
281 | String action = intent.getExtras().getString("actionname");
282 |
283 | switch (action){
284 | case CreateNotification.ACTION_PREVIOUS:
285 | onTrackPrevious();
286 | break;
287 | case CreateNotification.ACTION_NEXT:
288 | onTrackNext();
289 | break;
290 | case CreateNotification.ACTION_PLAY:
291 | if (isPlaying){
292 | onTrackPause();
293 | }else{
294 | onTrackPlay();
295 | }
296 | break;
297 | }
298 | }
299 | };
300 | @Override
301 | public void onTrackPrevious() {
302 | position--;
303 | CreateNotification.createNotification(PlayerActivity.this,songName,R.drawable.ic_baseline_pause,position,songs.size()-1);
304 | songs.get(position).getName();
305 | }
306 |
307 | @Override
308 | public void onTrackPause() {
309 | CreateNotification.createNotification(PlayerActivity.this,songName,R.drawable.ic_baseline_play_arrow,position,songs.size()-1);
310 | play.setBackgroundResource(R.drawable.ic_baseline_play_arrow);
311 | songs.get(position).getName();
312 | isPlaying = false;
313 | }
314 |
315 | @Override
316 | public void onTrackPlay() {
317 | CreateNotification.createNotification(PlayerActivity.this,songName,R.drawable.ic_baseline_pause,position,songs.size()-1);
318 | play.setBackgroundResource(R.drawable.ic_baseline_pause);
319 | songs.get(position).getName();
320 | isPlaying = true;
321 | }
322 |
323 | @Override
324 | public void onTrackNext() {
325 | position++;
326 | CreateNotification.createNotification(PlayerActivity.this,songName,R.drawable.ic_baseline_pause,position,songs.size()-1);
327 | songs.get(position).getName();
328 | }
329 |
330 | @Override
331 | protected void onDestroy() {
332 | super.onDestroy();
333 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
334 | notificationManager.cancelAll();
335 | }
336 | unregisterReceiver(broadcastReceiver);
337 | }
338 | }
339 |
--------------------------------------------------------------------------------