Add service and class to handle media playing.
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
set( simplecastengine_SRCS
|
set( simplecastengine_SRCS
|
||||||
simplecastengine.cpp
|
simplecastengine.cpp
|
||||||
|
minimediaplayer.cpp
|
||||||
|
simplecastservice.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library( plasma_dataengine_simplecastengine ${simplecastengine_SRCS} )
|
add_library(plasma_engine_simplecast ${simplecastengine_SRCS})
|
||||||
|
set_target_properties(plasma_engine_simplecast PROPERTIES PREFIX "")
|
||||||
|
|
||||||
kcoreaddons_desktop_to_json(plasma_dataengine_simplecastengine plasma_dataengine_simplecastengine.desktop)
|
kcoreaddons_desktop_to_json(plasma_engine_simplecast plasma-dataengine-simplecast.desktop)
|
||||||
|
|
||||||
target_link_libraries( plasma_dataengine_simplecastengine
|
target_link_libraries( plasma_engine_simplecast
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
KF5::Service
|
KF5::Service
|
||||||
KF5::I18n
|
KF5::I18n
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS plasma_dataengine_simplecastengine DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine)
|
install(TARGETS plasma_engine_simplecast DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine)
|
||||||
install( PROGRAMS org.eyecreate.simplecastengine.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
|
install(FILES simplecastcontrol.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services)
|
||||||
|
install(FILES plasma-dataengine-simplecast.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
|
||||||
|
|||||||
33
src/minimediaplayer.cpp
Normal file
33
src/minimediaplayer.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Simple Media Player that runs off a playlist.
|
||||||
|
* Copyright (C) 2019 Kevin Whitaker <eyecreate@eyecreate.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "minimediaplayer.h"
|
||||||
|
|
||||||
|
MiniMediaPlayer::MiniMediaPlayer(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaPlaylist* MiniMediaPlayer::playlist() const
|
||||||
|
{
|
||||||
|
return m_playlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaPlayer* MiniMediaPlayer::player() const
|
||||||
|
{
|
||||||
|
return m_player;
|
||||||
|
}
|
||||||
56
src/minimediaplayer.h
Normal file
56
src/minimediaplayer.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Simple Media Player that runs off a playlist.
|
||||||
|
* Copyright (C) 2019 Kevin Whitaker <eyecreate@eyecreate.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MINIMEDIAPLAYER_H
|
||||||
|
#define MINIMEDIAPLAYER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtMultimedia/QMediaPlayer>
|
||||||
|
#include <QtMultimedia/QMediaPlaylist>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
class MiniMediaPlayer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QMediaPlaylist playlist READ playlist)
|
||||||
|
Q_PROPERTY(QMediaPlayer player READ player)
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
MiniMediaPlayer(QObject *parent = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the playlist
|
||||||
|
*/
|
||||||
|
QMediaPlaylist *playlist() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the player
|
||||||
|
*/
|
||||||
|
QMediaPlayer *player() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMediaPlaylist *m_playlist;
|
||||||
|
QMediaPlayer *m_player;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MINIMEDIAPLAYER_H
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Simple Cast Engine
|
Name=Simple Cast
|
||||||
Comment=Data Engine that handles listing, queueing, and playing media URLs from other devices.
|
Comment=Data Engine that handles listing, queueing, and playing media URLs from other devices.
|
||||||
Type=Service
|
Type=Service
|
||||||
|
Icon=document-share
|
||||||
|
|
||||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||||
X-KDE-Library=plasma_dataengine_simplecast
|
X-KDE-Library=plasma_engine_simplecast
|
||||||
X-Plasma-EngineName=simplecast
|
X-Plasma-EngineName=org.eyecreate.simplecast
|
||||||
X-KDE-PluginInfo-Author=Kevin Whitaker
|
X-KDE-PluginInfo-Author=Kevin Whitaker
|
||||||
X-KDE-PluginInfo-Email=eyecreate@eyecreate.org
|
X-KDE-PluginInfo-Email=eyecreate@eyecreate.org
|
||||||
X-KDE-PluginInfo-Name=simplecast
|
X-KDE-PluginInfo-Name=simplecast
|
||||||
X-KDE-PluginInfo-Version=0.1
|
X-KDE-PluginInfo-Version=0.1
|
||||||
X-KDE-PluginInfo-Website=http://plasma.kde.org/
|
X-KDE-PluginInfo-Website=http://plasma.kde.org/
|
||||||
X-KDE-PluginInfo-Category=Examples
|
X-KDE-PluginInfo-Category=
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
X-KDE-PluginInfo-License=LGPL
|
X-KDE-PluginInfo-License=LGPL
|
||||||
X-KDE-PluginInfo-EnabledByDefault=true
|
X-KDE-PluginInfo-EnabledByDefault=true
|
||||||
16
src/simplecastcontrol.operations
Normal file
16
src/simplecastcontrol.operations
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE kcfg SYSTEM
|
||||||
|
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||||
|
<kcfg>
|
||||||
|
<group name="changePlayState">
|
||||||
|
<entry name="playing" type="Bool">
|
||||||
|
<label>Request to start or stop playing media.</label>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
<group name="skipToNextTrack"/>
|
||||||
|
<group name="addURLToPlaylist">
|
||||||
|
<entry name="URL" type="Url">
|
||||||
|
<label>URL to add to playlist.</label>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
</kcfg>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "simplecastengine.h"
|
#include "simplecastengine.h"
|
||||||
|
#include "simplecastservice.h"
|
||||||
|
|
||||||
SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args)
|
SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args)
|
||||||
: Plasma::DataEngine(parent,args)
|
: Plasma::DataEngine(parent,args)
|
||||||
@@ -29,16 +30,35 @@ SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args)
|
|||||||
|
|
||||||
bool SimpleCastEngine::sourceRequestEvent(const QString& source)
|
bool SimpleCastEngine::sourceRequestEvent(const QString& source)
|
||||||
{
|
{
|
||||||
return updateSourceEvent(source);//TODO
|
setData(source, "you found me");
|
||||||
|
return true;
|
||||||
|
//return updateSourceEvent(source);//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleCastEngine::updateSourceEvent(const QString& source)
|
bool SimpleCastEngine::updateSourceEvent(const QString& source)
|
||||||
{
|
{
|
||||||
|
//Source for current playlist(contains title and url)
|
||||||
|
//Source for current track time and length, and playing state
|
||||||
|
setData(source, "you found me again");
|
||||||
return true;//TODO
|
return true;//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList SimpleCastEngine::sources() const
|
||||||
|
{
|
||||||
|
return QStringList() << "Playlist" << "CurrentState";
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasma::Service * SimpleCastEngine::serviceForSource(const QString& source)
|
||||||
|
{
|
||||||
|
if(source == "CurrentState")
|
||||||
|
{
|
||||||
|
return new SimpleCastService(source, this);
|
||||||
|
}
|
||||||
|
return Plasma::DataEngine::serviceForSource(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
K_EXPORT_PLASMA_DATAENGINE(simplecast, SimpleCastEngine)
|
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.eyecreate.simplecast, SimpleCastEngine,"plasma-dataengine-simplecast.json")
|
||||||
|
|
||||||
#include "simplecastengine.moc"
|
#include "simplecastengine.moc"
|
||||||
|
|||||||
@@ -23,16 +23,19 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
#include <Plasma/DataEngine>
|
||||||
|
#include <qt5/QtCore/QString>
|
||||||
|
|
||||||
class SimpleCastEngine : public Plasma::DataEngine
|
class SimpleCastEngine : public Plasma::DataEngine
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SimpleCastEngine(QObject *parent, const QVariantList &args);
|
SimpleCastEngine(QObject *parent, const QVariantList &args);
|
||||||
|
QStringList sources() const override;
|
||||||
|
Plasma::Service *serviceForSource(const QString &source) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool sourceRequestEvent(const QString &source);
|
bool sourceRequestEvent(const QString &source) override;
|
||||||
bool updateSourceEvent(const QString &source);
|
bool updateSourceEvent(const QString &source) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
38
src/simplecastservice.cpp
Normal file
38
src/simplecastservice.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* <one line to give the program's name and a brief idea of what it does.>
|
||||||
|
* Copyright (C) 2019 <copyright holder> <email>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "simplecastservice.h"
|
||||||
|
|
||||||
|
SimpleCastService::SimpleCastService(const QString &destination, QObject *parent) : Plasma::Service(parent)
|
||||||
|
{
|
||||||
|
setName("simplecastcontrol");
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleCastService::~SimpleCastService()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Plasma::ServiceJob* SimpleCastService::createJob(const QString& operation, QVariantMap& parameters)
|
||||||
|
{
|
||||||
|
return NULL; //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
//K_EXPORT_PLASMA_SERVICE(org.eyecreate.simplecast, SimpleCastService)
|
||||||
|
|
||||||
|
#include "simplecastservice.moc"
|
||||||
45
src/simplecastservice.h
Normal file
45
src/simplecastservice.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* <one line to give the program's name and a brief idea of what it does.>
|
||||||
|
* Copyright (C) 2019 <copyright holder> <email>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLECASTSERVICE_H
|
||||||
|
#define SIMPLECASTSERVICE_H
|
||||||
|
|
||||||
|
#include <Plasma/Service>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
class SimpleCastService : public Plasma::Service
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SimpleCastService(const QString &destination, QObject *parent = 0);
|
||||||
|
~SimpleCastService();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*
|
||||||
|
* @param operation TODO
|
||||||
|
* @param parameters TODO
|
||||||
|
* @return TODO
|
||||||
|
*/
|
||||||
|
Plasma::ServiceJob* createJob(const QString& operation, QVariantMap& parameters) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SIMPLECASTSERVICE_H
|
||||||
Reference in New Issue
Block a user