Added qDebugs and create instance of MediaSessionClient.
This commit is contained in:
parent
1ae780fe63
commit
deb8cac131
@ -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="1628978137"
|
android:versionCode="1629047915"
|
||||||
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"/>
|
||||||
|
@ -34,6 +34,12 @@ public class KastsActivity extends QtActivity
|
|||||||
{
|
{
|
||||||
private static final String TAG = "org.kde.kasts.mediasession";
|
private static final String TAG = "org.kde.kasts.mediasession";
|
||||||
|
|
||||||
|
private static native void playerPlay();
|
||||||
|
private static native void playerPause();
|
||||||
|
private static native void playerStop();
|
||||||
|
private static native void playerNext();
|
||||||
|
private static native void playerSeek(long position);
|
||||||
|
|
||||||
class MediaData {
|
class MediaData {
|
||||||
public String title;
|
public String title;
|
||||||
public String author;
|
public String author;
|
||||||
@ -175,7 +181,7 @@ public class KastsActivity extends QtActivity
|
|||||||
|
|
||||||
mSession.setActive(true);
|
mSession.setActive(true);
|
||||||
|
|
||||||
play();
|
playerPlay();
|
||||||
|
|
||||||
//Update variables of mediaData;
|
//Update variables of mediaData;
|
||||||
activity.updateNotification();
|
activity.updateNotification();
|
||||||
@ -258,10 +264,4 @@ public class KastsActivity extends QtActivity
|
|||||||
|
|
||||||
activity.updateNotification();
|
activity.updateNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void play();
|
|
||||||
private static native void pause();
|
|
||||||
private static native void stop();
|
|
||||||
private static native void next();
|
|
||||||
private static native void seek(long position);
|
|
||||||
}
|
}
|
||||||
|
@ -15,37 +15,42 @@ static void play(JNIEnv *env, jobject thiz)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(env)
|
Q_UNUSED(env)
|
||||||
Q_UNUSED(thiz)
|
Q_UNUSED(thiz)
|
||||||
|
qDebug() << "JAVA play() working.";
|
||||||
// audio manager play
|
// audio manager play
|
||||||
}
|
}
|
||||||
static void pause(JNIEnv *env, jobject thiz)
|
static void pause(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
Q_UNUSED(env)
|
Q_UNUSED(env)
|
||||||
Q_UNUSED(thiz)
|
Q_UNUSED(thiz)
|
||||||
|
qDebug() << "JAVA pause() working.";
|
||||||
// audio manager pause
|
// audio manager pause
|
||||||
}
|
}
|
||||||
static void stop(JNIEnv *env, jobject thiz)
|
static void stop(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
Q_UNUSED(env)
|
Q_UNUSED(env)
|
||||||
Q_UNUSED(thiz)
|
Q_UNUSED(thiz)
|
||||||
|
qDebug() << "JAVA stop() working.";
|
||||||
//audio manager previous
|
//audio manager previous
|
||||||
}
|
}
|
||||||
static void next(JNIEnv *env, jobject thiz)
|
static void next(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
Q_UNUSED(env)
|
Q_UNUSED(env)
|
||||||
Q_UNUSED(thiz)
|
Q_UNUSED(thiz)
|
||||||
|
qDebug() << "JAVA next() working.";
|
||||||
// audio manager next
|
// audio manager next
|
||||||
}
|
}
|
||||||
static void seek(JNIEnv *env, jobject thiz, jlong position)
|
static void seek(JNIEnv *env, jobject thiz, jlong position)
|
||||||
{
|
{
|
||||||
Q_UNUSED(env)
|
Q_UNUSED(env)
|
||||||
Q_UNUSED(thiz)
|
Q_UNUSED(thiz)
|
||||||
|
qDebug() << "JAVA seek() working.";
|
||||||
// implement seek
|
// implement seek
|
||||||
}
|
}
|
||||||
static const JNINativeMethod methods[] {{"play", "()V", reinterpret_cast<void *>(play)},
|
static const JNINativeMethod methods[] {{"playerPlay", "()V", reinterpret_cast<void *>(play)},
|
||||||
{"pause", "()V", reinterpret_cast<void *>(pause)},
|
{"playerPause", "()V", reinterpret_cast<void *>(pause)},
|
||||||
{"stop", "()V", reinterpret_cast<void *>(stop)},
|
{"playerStop", "()V", reinterpret_cast<void *>(stop)},
|
||||||
{"next", "()V", reinterpret_cast<void *>(next)},
|
{"playerNext", "()V", reinterpret_cast<void *>(next)},
|
||||||
{"seek", "(J)V", reinterpret_cast<void *>(seek)}};
|
{"playerSeek", "(J)V", reinterpret_cast<void *>(seek)}};
|
||||||
|
|
||||||
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
|
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
|
||||||
{
|
{
|
||||||
@ -67,10 +72,13 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
|
|||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSessionClient* MediaSessionClient::s_instance = nullptr;
|
||||||
|
|
||||||
MediaSessionClient::MediaSessionClient(AudioManager *audioPlayer, QObject *parent)
|
MediaSessionClient::MediaSessionClient(AudioManager *audioPlayer, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_audioPlayer(audioPlayer)
|
, m_audioPlayer(audioPlayer)
|
||||||
{
|
{
|
||||||
|
s_instance = this;
|
||||||
connect(m_audioPlayer, &AudioManager::playbackStateChanged, this, &MediaSessionClient::setSessionPlaybackState);
|
connect(m_audioPlayer, &AudioManager::playbackStateChanged, this, &MediaSessionClient::setSessionPlaybackState);
|
||||||
// Sets the current playback state.
|
// Sets the current playback state.
|
||||||
connect(m_audioPlayer, &AudioManager::entryChanged, this, &MediaSessionClient::setSessionMetadata);
|
connect(m_audioPlayer, &AudioManager::entryChanged, this, &MediaSessionClient::setSessionMetadata);
|
||||||
@ -89,6 +97,11 @@ MediaSessionClient::MediaSessionClient(AudioManager *audioPlayer, QObject *paren
|
|||||||
// Sets the playback to stopped.
|
// Sets the playback to stopped.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSessionClient* MediaSessionClient::instance()
|
||||||
|
{
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
void MediaSessionClient::setSessionPlaybackState()
|
void MediaSessionClient::setSessionPlaybackState()
|
||||||
{
|
{
|
||||||
qDebug() << "MediaSessionClient::setSessionPlaybackState called with state value = " << m_audioPlayer->playbackState();
|
qDebug() << "MediaSessionClient::setSessionPlaybackState called with state value = " << m_audioPlayer->playbackState();
|
||||||
|
@ -16,6 +16,10 @@ class MediaSessionClient : public QObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MediaSessionClient(AudioManager *audioPlayer, QObject *parent = nullptr);
|
explicit MediaSessionClient(AudioManager *audioPlayer, QObject *parent = nullptr);
|
||||||
|
static MediaSessionClient* instance();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void play();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void setSessionPlaybackState();
|
void setSessionPlaybackState();
|
||||||
@ -26,4 +30,5 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
AudioManager *m_audioPlayer = nullptr;
|
AudioManager *m_audioPlayer = nullptr;
|
||||||
|
static MediaSessionClient *s_instance;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user