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

replace phonon with QtMultimedia

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