mirror of
https://github.com/KDE/kasts.git
synced 2024-12-18 03:29:35 +01:00
Add logging and apply clang-format
This commit is contained in:
parent
27d5311171
commit
51973e8ff5
@ -94,6 +94,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Log.d(TAG, "JAVA onCreate of MediaSession called.");
|
||||
|
||||
mediaSession = new MediaSessionCompat(this, TAG);
|
||||
mediaSession.setFlags(
|
||||
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
|
||||
@ -111,6 +113,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
Log.d(TAG, "JAVA onDestroy of MediaSession called.");
|
||||
|
||||
mediaSession.release();
|
||||
}
|
||||
|
||||
@ -127,6 +131,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onPlay() {
|
||||
super.onPlay();
|
||||
|
||||
Log.d(TAG, "JAVA onDestroy of onPlay callback called.");
|
||||
|
||||
if (!mediaSession.isActive()) {
|
||||
mediaSession.setActive(true);
|
||||
}
|
||||
@ -136,6 +142,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
Log.d(TAG, "JAVA onDestroy of onPause callback called.");
|
||||
|
||||
//JNI to audiomanager pause
|
||||
//setPlaybackState for mediaSession
|
||||
}
|
||||
@ -144,6 +152,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
Log.d(TAG, "JAVA onDestroy of onStop callback called.");
|
||||
|
||||
//JNI call to audiomanager stop
|
||||
mediaSession.setActive(false);
|
||||
}
|
||||
@ -152,6 +162,8 @@ public class KastsActivity extends QtActivity
|
||||
public void onSkipToNext() {
|
||||
super.onPause();
|
||||
|
||||
Log.d(TAG, "JAVA onDestroy of onSkipToNext callback called.");
|
||||
|
||||
//JNI to audiomanager next
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,10 @@
|
||||
#include "audiologging.h"
|
||||
#include "datamanager.h"
|
||||
#include "feed.h"
|
||||
#include "mediasessionclient.h"
|
||||
#include "models/errorlogmodel.h"
|
||||
#include "powermanagementinterface.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "mediasessionclient.h"
|
||||
|
||||
class AudioManagerPrivate
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Swapnil Tripathi <swapnil06.st@gmail.com>
|
||||
* SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "mediasessionclient.h"
|
||||
#include "audiomanager.h"
|
||||
@ -9,8 +9,8 @@
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QAndroidJniObject>
|
||||
#include <QAndroidJniEnvironment>
|
||||
#include <QAndroidJniObject>
|
||||
|
||||
static void play(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
@ -40,10 +40,10 @@ static void seek(JNIEnv *env, jobject thiz, jlong position)
|
||||
Q_UNUSED(position)
|
||||
qWarning() << "JAVA seek() working.";
|
||||
}
|
||||
static const JNINativeMethod methods[] {{"playerPlay", "()V", reinterpret_cast<void *>(play)},
|
||||
{"playerPause", "()V", reinterpret_cast<void *>(pause)},
|
||||
{"playerNext", "()V", reinterpret_cast<void *>(next)},
|
||||
{"playerSeek", "(J)V", reinterpret_cast<void *>(seek)}};
|
||||
static const JNINativeMethod methods[]{{"playerPlay", "()V", reinterpret_cast<void *>(play)},
|
||||
{"playerPause", "()V", reinterpret_cast<void *>(pause)},
|
||||
{"playerNext", "()V", reinterpret_cast<void *>(next)},
|
||||
{"playerSeek", "(J)V", reinterpret_cast<void *>(seek)}};
|
||||
|
||||
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
|
||||
{
|
||||
@ -66,7 +66,7 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
|
||||
}
|
||||
#endif
|
||||
|
||||
MediaSessionClient* MediaSessionClient::s_instance = nullptr;
|
||||
MediaSessionClient *MediaSessionClient::s_instance = nullptr;
|
||||
|
||||
MediaSessionClient::MediaSessionClient(AudioManager *audioPlayer, QObject *parent)
|
||||
: QObject(parent)
|
||||
@ -97,7 +97,7 @@ MediaSessionClient::MediaSessionClient(AudioManager *audioPlayer, QObject *paren
|
||||
// Connect android notification's play action to skip to next media.
|
||||
}
|
||||
|
||||
MediaSessionClient* MediaSessionClient::instance()
|
||||
MediaSessionClient *MediaSessionClient::instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
@ -106,7 +106,7 @@ void MediaSessionClient::setSessionPlaybackState()
|
||||
{
|
||||
qWarning() << "MediaSessionClient::setSessionPlaybackState called with state value = " << m_audioPlayer->playbackState();
|
||||
int status = -1;
|
||||
switch(m_audioPlayer->playbackState()) {
|
||||
switch (m_audioPlayer->playbackState()) {
|
||||
case QMediaPlayer::PlayingState:
|
||||
status = 0;
|
||||
break;
|
||||
@ -135,7 +135,7 @@ void MediaSessionClient::setSessionMetadata()
|
||||
if (entry->authors().count() > 0) {
|
||||
for (auto &author : entry->authors()) {
|
||||
authorString.append(author->name());
|
||||
if(entry->authors().count() > 1)
|
||||
if (entry->authors().count() > 1)
|
||||
authorString.append(QStringLiteral(", "));
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,15 @@ void MediaSessionClient::setSessionMetadata()
|
||||
int rate = m_audioPlayer->playbackRate();
|
||||
// Playback rate
|
||||
|
||||
QAndroidJniObject::callStaticMethod<void>("org/kde/kasts/KastsActivity", "setMetadata","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JJF)V",title.object<jstring>(), author.object<jstring>(), album.object<jstring>(), (jlong)position, (jlong)duration, (jfloat)rate);
|
||||
QAndroidJniObject::callStaticMethod<void>("org/kde/kasts/KastsActivity",
|
||||
"setMetadata",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JJF)V",
|
||||
title.object<jstring>(),
|
||||
author.object<jstring>(),
|
||||
album.object<jstring>(),
|
||||
(jlong)position,
|
||||
(jlong)duration,
|
||||
(jfloat)rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Swapnil Tripathi <swapnil06.st@gmail.com>
|
||||
* SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -19,7 +19,7 @@ class MediaSessionClient : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MediaSessionClient(AudioManager *audioPlayer, QObject *parent = nullptr);
|
||||
static MediaSessionClient* instance();
|
||||
static MediaSessionClient *instance();
|
||||
|
||||
Q_SIGNALS:
|
||||
void play();
|
||||
|
Loading…
Reference in New Issue
Block a user