Using the meta data and adding android log messages.

This commit is contained in:
Swapnil Tripathi 2021-08-14 22:55:25 +05:30 committed by Tobias Fella
parent fcc4b238be
commit 3e9c4a9eb8
2 changed files with 15 additions and 12 deletions

View File

@ -7,7 +7,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.kde.kasts" package="org.kde.kasts"
android:versionName="0.0.1" android:versionName="0.0.1"
android:versionCode="1628953797" android:versionCode="1628961273"
android:installLocation="auto"> android:installLocation="auto">
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

View File

@ -68,16 +68,14 @@ public class KastsActivity extends QtActivity
mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed); mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed);
} }
metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, "The title"); metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mediaData.title);
metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, "Author"); metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, mediaData.author);
metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, "Author"); metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mediaData.author);
metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, "The album"); metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, mediaData.album);
metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, 1000000); metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, mediaData.duration);
//TODO Image //TODO Image
mSession.setMetadata(metadata.build()); mSession.setMetadata(metadata.build());
mPBuilder.setState(PlaybackStateCompat.STATE_PLAYING, 100000, 1.0f); //TODO:Logically we should remove this statement??
Intent iPlay = new Intent(this, MediaSessionCallback.class); Intent iPlay = new Intent(this, MediaSessionCallback.class);
iPlay.setAction("ACTION_PLAY"); iPlay.setAction("ACTION_PLAY");
PendingIntent piPlay = PendingIntent.getBroadcast(this, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piPlay = PendingIntent.getBroadcast(this, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT);
@ -110,10 +108,10 @@ public class KastsActivity extends QtActivity
.setAutoCancel(false) .setAutoCancel(false)
.setShowWhen(false) .setShowWhen(false)
.setVisibility(androidx.core.app.NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(androidx.core.app.NotificationCompat.VISIBILITY_PUBLIC)
.setSubText("foobar") .setSubText(mediaData.author)
.setContentTitle("Foo's title") .setContentTitle(mediaData.title)
.setSmallIcon(this.getApplicationInfo().icon) .setSmallIcon(this.getApplicationInfo().icon)
.setChannelId("org.kde.neochat.channel") .setChannelId("org.kde.kasts.channel")
.setContentText("some random text"); .setContentText("some random text");
notification.addAction(aPrevious.build()); notification.addAction(aPrevious.build());
@ -127,7 +125,7 @@ public class KastsActivity extends QtActivity
notification.setGroup("MprisMediaSession"); notification.setGroup("MprisMediaSession");
mSession.setActive(true); mSession.setActive(true);
NotificationManager nm = ContextCompat.getSystemService(this, NotificationManager.class); NotificationManager nm = ContextCompat.getSystemService(this, NotificationManager.class);
NotificationChannel channel = new NotificationChannel("org.kde.neochat.channel", "KastsChannel", NotificationManager.IMPORTANCE_HIGH); NotificationChannel channel = new NotificationChannel("org.kde.kasts.channel", "KastsChannel", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("The notification channel"); channel.setDescription("The notification channel");
channel.enableLights(false); channel.enableLights(false);
channel.enableVibration(false); channel.enableVibration(false);
@ -207,12 +205,14 @@ public class KastsActivity extends QtActivity
//TODO: set state in mediadata //TODO: set state in mediadata
mediaData.state = state; mediaData.state = state;
Log.d(TAG, "JAVA setSessionState called.");
activity.updateNotification(); activity.updateNotification();
} }
public static void setMetadata(String title, String author, String album, long position, long duration, float rate) public static void setMetadata(String title, String author, String album, long position, long duration, float rate)
{ {
Log.d(TAG, "JAVA setMetadata called.");
mediaData.title = title; mediaData.title = title;
mediaData.author = author; mediaData.author = author;
mediaData.album = album; mediaData.album = album;
@ -225,6 +225,7 @@ public class KastsActivity extends QtActivity
public static void setPlaybackSpeed(int rate) public static void setPlaybackSpeed(int rate)
{ {
Log.d(TAG, "JAVA setPlaybackSpeed called.");
mediaData.playbackSpeed = rate; mediaData.playbackSpeed = rate;
activity.updateNotification(); activity.updateNotification();
@ -232,6 +233,7 @@ public class KastsActivity extends QtActivity
public static void setDuration(int duration) public static void setDuration(int duration)
{ {
Log.d(TAG, "JAVA setDuration called.");
mediaData.duration = duration; mediaData.duration = duration;
activity.updateNotification(); activity.updateNotification();
@ -239,6 +241,7 @@ public class KastsActivity extends QtActivity
public static void setPosition(int position) public static void setPosition(int position)
{ {
Log.d(TAG, "JAVA setPosition called.");
mediaData.position = position; mediaData.position = position;
activity.updateNotification(); activity.updateNotification();