Commit 5b73c081 authored by Piyush Aggarwal's avatar Piyush Aggarwal 👋 Committed by Nicolas Fella

replace phonon with QtMultimedia

parent 459a1992
Pipeline #2945 passed with stage
in 17 minutes and 1 second
......@@ -48,12 +48,7 @@ if (NOT ZSH_AUTOCOMPLETE_DIR)
set(ZSH_AUTOCOMPLETE_DIR "${CMAKE_INSTALL_PREFIX}/share/zsh/site-functions")
endif()
find_package(Phonon4Qt5 4.9.0 NO_MODULE)
set_package_properties(Phonon4Qt5 PROPERTIES
DESCRIPTION "Qt-based audio library"
TYPE OPTIONAL
PURPOSE "Required for Find My Device plugin"
)
find_package(Qt5Multimedia)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "QtQuick plugins to build user interfaces based on KDE UX guidelines"
......
......@@ -24,7 +24,7 @@ if(NOT SAILFISHOS)
add_subdirectory(sftp)
endif()
if(Phonon4Qt5_FOUND)
if(Qt5Multimedia_FOUND)
add_subdirectory(findthisdevice)
endif()
endif()
......
include_directories(${PHONON_INCLUDE_DIR})
set(kdeconnect_findthisdevice_SRCS
findthisdeviceplugin.cpp
)
......@@ -10,8 +8,8 @@ kdeconnect_add_plugin(kdeconnect_findthisdevice
target_link_libraries(kdeconnect_findthisdevice
kdeconnectcore
${PHONON_LIBRARIES}
Qt5::Core
Qt5::Multimedia
Qt5::DBus
)
......@@ -22,7 +20,7 @@ ki18n_wrap_ui(kdeconnect_findthisdevice_config_SRCS findthisdevice_config.ui)
add_library(kdeconnect_findthisdevice_config MODULE ${kdeconnect_findthisdevice_config_SRCS})
target_link_libraries(kdeconnect_findthisdevice_config
kdeconnectpluginkcm
${PHONON_LIBRARIES}
Qt5::Multimedia
KF5::I18n
KF5::CoreAddons
KF5::ConfigWidgets
......
......@@ -22,13 +22,12 @@
#include "findthisdeviceplugin.h"
#include "ui_findthisdevice_config.h"
// Phonon
#include <phonon/mediaobject.h>
// KF
#include <KLocalizedString>
#include <KPluginFactory>
// Qt
#include <QStandardPaths>
#include <QMediaPlayer>
K_PLUGIN_FACTORY(FindThisDeviceConfigFactory, registerPlugin<FindThisDeviceConfig>();)
......@@ -108,10 +107,13 @@ void FindThisDeviceConfig::playSound()
}
soundURL.clear();
}
QMediaPlayer* player = new QMediaPlayer;
player->setAudioRole(QAudio::Role(QAudio::NotificationRole));
player->setMedia(soundURL);
player->setVolume(100);
player->play();
connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater);
Phonon::MediaObject *media = Phonon::createPlayer(Phonon::NotificationCategory, soundURL);
media->play();
connect(media, SIGNAL(finished()), media, SLOT(deleteLater()));
}
......
......@@ -20,8 +20,6 @@
#include "findthisdeviceplugin.h"
// Phonon
#include <phonon/mediaobject.h>
// KF
#include <KPluginFactory>
// Qt
......@@ -29,7 +27,7 @@
#include <QStandardPaths>
#include <QFile>
#include <QUrl>
#include <QMediaPlayer>
K_PLUGIN_FACTORY_WITH_JSON(KdeConnectPluginFactory, "kdeconnect_findthisdevice.json",
registerPlugin<FindThisDevicePlugin>();)
......@@ -88,10 +86,12 @@ bool FindThisDevicePlugin::receivePacket(const NetworkPacket& np)
return true;
}
Phonon::MediaObject *media = Phonon::createPlayer(Phonon::NotificationCategory, soundURL); // or CommunicationCategory?
media->play();
connect(media, &Phonon::MediaObject::finished, media, &QObject::deleteLater);
QMediaPlayer* player = new QMediaPlayer;
player->setAudioRole(QAudio::Role(QAudio::NotificationRole));
player->setMedia(soundURL);
player->setVolume(100);
player->play();
connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater);
// TODO: by-pass volume settings in case it is muted
// TODO: ensure to use built-in loudspeakers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment