From ba2cb1b506e0c4c9aa8f9a2cb2ccf43da96d420c Mon Sep 17 00:00:00 2001
From: GamerPlayer888 <66787796+gamerplayer888@users.noreply.github.com>
Date: Mon, 22 Dec 2025 02:39:41 +0100
Subject: [PATCH 1/5] removed source to env.sh that broken CI
---
n_player/compile_rust.sh | 1 -
n_player/compile_rust_release.sh | 1 -
2 files changed, 2 deletions(-)
diff --git a/n_player/compile_rust.sh b/n_player/compile_rust.sh
index f82b078..542e4d4 100644
--- a/n_player/compile_rust.sh
+++ b/n_player/compile_rust.sh
@@ -1,2 +1 @@
-source env.sh
cargo ndk -t arm64-v8a -o android/src/main/jniLibs/ -p 30 build --package n_player --lib --no-default-features
\ No newline at end of file
diff --git a/n_player/compile_rust_release.sh b/n_player/compile_rust_release.sh
index 6574106..6b90ccf 100644
--- a/n_player/compile_rust_release.sh
+++ b/n_player/compile_rust_release.sh
@@ -1,2 +1 @@
-source env.sh
cargo ndk -t arm64-v8a -o android/src/main/jniLibs/ -p 30 build --package n_player --lib --no-default-features --release
\ No newline at end of file
From 4f228383eb8e7d743cd64914cd5f1713f19d21bf Mon Sep 17 00:00:00 2001
From: GamerPlayer888 <66787796+gamerplayer888@users.noreply.github.com>
Date: Mon, 22 Dec 2025 02:40:57 +0100
Subject: [PATCH 2/5] new N Music icon, monochrome
---
.../res/drawable/ic_launcher_monochrome.xml | 396 ++++++++++++++++++
1 file changed, 396 insertions(+)
create mode 100644 n_player/android/src/main/res/drawable/ic_launcher_monochrome.xml
diff --git a/n_player/android/src/main/res/drawable/ic_launcher_monochrome.xml b/n_player/android/src/main/res/drawable/ic_launcher_monochrome.xml
new file mode 100644
index 0000000..bcb7fdf
--- /dev/null
+++ b/n_player/android/src/main/res/drawable/ic_launcher_monochrome.xml
@@ -0,0 +1,396 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 621e7c7d1039bc6f4da4799145dc7449a01ba179 Mon Sep 17 00:00:00 2001
From: GamerPlayer888 <66787796+gamerplayer888@users.noreply.github.com>
Date: Mon, 22 Dec 2025 02:54:02 +0100
Subject: [PATCH 3/5] monochrome icon support and update manifest config
---
n_player/android/src/main/AndroidManifest.xml | 5 +++++
.../android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 1 +
.../src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 1 +
3 files changed, 7 insertions(+)
diff --git a/n_player/android/src/main/AndroidManifest.xml b/n_player/android/src/main/AndroidManifest.xml
index f3a4107..3745c54 100644
--- a/n_player/android/src/main/AndroidManifest.xml
+++ b/n_player/android/src/main/AndroidManifest.xml
@@ -15,9 +15,14 @@
android:supportsRtl="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
+
diff --git a/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
index 7353dbd..1413a31 100644
--- a/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ b/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -2,4 +2,5 @@
+
\ No newline at end of file
diff --git a/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
index 7353dbd..1413a31 100644
--- a/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ b/n_player/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -2,4 +2,5 @@
+
\ No newline at end of file
From c6959282743b4a0054d795a6f08d0d50e9ad546c Mon Sep 17 00:00:00 2001
From: GamerPlayer888 <66787796+gamerplayer888@users.noreply.github.com>
Date: Mon, 22 Dec 2025 02:58:14 +0100
Subject: [PATCH 4/5] removed DummyService and update notification intent As in
manifest launchMode is set to 'singleTask', app will not crash when intent is
launched
---
n_player/android/src/main/AndroidManifest.xml | 12 ------------
.../com/enn3developer/n_music/DummyService.kt | 16 ----------------
.../com/enn3developer/n_music/MainActivity.kt | 10 +++++++---
3 files changed, 7 insertions(+), 31 deletions(-)
delete mode 100644 n_player/android/src/main/java/com/enn3developer/n_music/DummyService.kt
diff --git a/n_player/android/src/main/AndroidManifest.xml b/n_player/android/src/main/AndroidManifest.xml
index 3745c54..5f20999 100644
--- a/n_player/android/src/main/AndroidManifest.xml
+++ b/n_player/android/src/main/AndroidManifest.xml
@@ -33,18 +33,6 @@
android:value="n_player"
/>
-
-
-
-
-
-
-
diff --git a/n_player/android/src/main/java/com/enn3developer/n_music/DummyService.kt b/n_player/android/src/main/java/com/enn3developer/n_music/DummyService.kt
deleted file mode 100644
index f115211..0000000
--- a/n_player/android/src/main/java/com/enn3developer/n_music/DummyService.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.enn3developer.n_music
-
-import android.app.Service
-import android.content.Intent
-import android.os.IBinder
-
-/**
- * DummyService is a service that acts as a placeholder when setting up content intents in notification.
- * It prevents the application from crashing when the intent is called
- */
-
-class DummyService : Service() {
- override fun onBind(intent: Intent): IBinder? {
- return null
- }
-}
\ No newline at end of file
diff --git a/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt b/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
index 2bee06b..20f90f0 100644
--- a/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
+++ b/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
@@ -186,9 +186,14 @@ class MainActivity : NativeActivity() {
coverPath: String,
songLength: Double
) {
- val intent = Intent(applicationContext, DummyService::class.java).apply {
- flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
+ var intent = applicationContext.packageManager.getLaunchIntentForPackage(packageName)
+
+ if (intent == null) {
+ intent = Intent(applicationContext, MainActivity::class.java)
}
+
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
+
val pendingIntent =
PendingIntent.getActivity(
applicationContext, 0, intent,
@@ -242,7 +247,6 @@ class MainActivity : NativeActivity() {
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(NOTIFICATION_ID)
- stopService(Intent(this, DummyService::class.java))
super.onDestroy()
}
From c42c6c2a12592b6e47f6f06a6ecc842c06d4ae0c Mon Sep 17 00:00:00 2001
From: GamerPlayer888 <66787796+gamerplayer888@users.noreply.github.com>
Date: Mon, 22 Dec 2025 03:10:21 +0100
Subject: [PATCH 5/5] refactor media callback and notification config
---
.../com/enn3developer/n_music/MainActivity.kt | 9 ++--
.../enn3developer/n_music/MediaCallback.kt | 42 ++++++++++---------
2 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt b/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
index 20f90f0..803d3bf 100644
--- a/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
+++ b/n_player/android/src/main/java/com/enn3developer/n_music/MainActivity.kt
@@ -58,6 +58,7 @@ class MainActivity : NativeActivity() {
const val ASK_DIRECTORY = 0
const val ASK_FILE = 1
const val REQUEST_PERMISSION_CODE = 1
+ const val ACTIONS = PlaybackState.ACTION_PLAY or PlaybackState.ACTION_PAUSE or PlaybackState.ACTION_SKIP_TO_NEXT or PlaybackState.ACTION_SKIP_TO_PREVIOUS or PlaybackState.ACTION_SEEK_TO
}
@SuppressLint("RestrictedApi")
@@ -130,12 +131,13 @@ class MainActivity : NativeActivity() {
mediaSession = MediaSession(applicationContext, TAG)
val handler = Handler(Looper.getMainLooper())
handler.post {
- mediaSession?.setCallback(MediaCallback(mediaSession!!, playback!!))
+ mediaSession?.setCallback(MediaCallback(mediaSession!!, this))
}
val bluetoothReceiver = IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY)
applicationContext.registerReceiver(bluetoothBroadcastReceiver, bluetoothReceiver)
playback = PlaybackState.Builder()
- .setActions(PlaybackState.ACTION_PLAY or PlaybackState.ACTION_PAUSE or PlaybackState.ACTION_SKIP_TO_NEXT or PlaybackState.ACTION_SKIP_TO_PREVIOUS or PlaybackState.ACTION_SEEK_TO)
+ .setActions(ACTIONS)
+ .setActiveQueueItemId(ACTIONS)
val channel = NotificationChannel(
CHANNEL_ID,
NOTIFICATION_NAME_SERVICE,
@@ -148,8 +150,9 @@ class MainActivity : NativeActivity() {
mediaSession?.setPlaybackState(playback?.build())
NotificationManagerCompat.from(applicationContext).createNotificationChannel(channel)
notification = Notification.Builder(applicationContext, CHANNEL_ID).apply {
- setSmallIcon(R.mipmap.ic_launcher_round)
+ setSmallIcon(R.drawable.ic_launcher_monochrome)
style = Notification.MediaStyle().setMediaSession(mediaSession?.sessionToken)
+ setOngoing(true)
}
}
diff --git a/n_player/android/src/main/java/com/enn3developer/n_music/MediaCallback.kt b/n_player/android/src/main/java/com/enn3developer/n_music/MediaCallback.kt
index 932c9bc..ab65791 100644
--- a/n_player/android/src/main/java/com/enn3developer/n_music/MediaCallback.kt
+++ b/n_player/android/src/main/java/com/enn3developer/n_music/MediaCallback.kt
@@ -4,9 +4,11 @@ import android.media.session.MediaSession
import android.media.session.PlaybackState
// Called in mediaSession callback when we interact with notification
-class MediaCallback(private val mediaSession: MediaSession,
- private val playback: PlaybackState.Builder
+class MediaCallback(
+ private val mediaSession: MediaSession,
+ private val activity: MainActivity
) : MediaSession.Callback() {
+
private external fun TogglePause()
private external fun PlayNext()
private external fun PlayPrevious()
@@ -14,24 +16,26 @@ class MediaCallback(private val mediaSession: MediaSession,
override fun onPause() {
TogglePause()
- mediaSession.controller.playbackState?.position?.let {
- playback.setState(
- PlaybackState.STATE_PAUSED,
- it, 1.0f
- )
- }
- mediaSession.setPlaybackState(playback.build())
+ val position = mediaSession.controller.playbackState?.position ?: 0L
+
+ activity.playback?.setState(
+ PlaybackState.STATE_PAUSED,
+ position, 1.0f
+ )
+
+ mediaSession.setPlaybackState(activity.playback?.build())
super.onPause()
}
override fun onPlay() {
TogglePause()
- mediaSession.controller.playbackState?.position?.let {
- playback.setState(
- PlaybackState.STATE_PLAYING,
- it, 1.0f)
- }
- mediaSession.setPlaybackState(playback.build())
+ val position = mediaSession.controller.playbackState?.position ?: 0L
+
+ activity.playback?.setState(
+ PlaybackState.STATE_PLAYING,
+ position, 1.0f
+ )
+ mediaSession.setPlaybackState(activity.playback?.build())
super.onPlay()
}
@@ -42,15 +46,15 @@ class MediaCallback(private val mediaSession: MediaSession,
override fun onSkipToPrevious() {
PlayPrevious()
- playback.setState(PlaybackState.STATE_PLAYING, 0L, 1.0f)
- mediaSession.setPlaybackState(playback.build())
+ activity.playback?.setState(PlaybackState.STATE_PLAYING, 0L, 1.0f)
+ mediaSession.setPlaybackState(activity.playback?.build())
super.onSkipToPrevious()
}
override fun onSeekTo(pos: Long) {
Seek((pos / 1000).toDouble())
- playback.setState(PlaybackState.STATE_PLAYING, pos, 1.0f)
- mediaSession.setPlaybackState(playback.build())
+ activity.playback?.setState(PlaybackState.STATE_PLAYING, pos, 1.0f)
+ mediaSession.setPlaybackState(activity.playback?.build())
super.onSeekTo(pos)
}
}
\ No newline at end of file