Commit 8bf9bef9 authored by Kevin Whitaker's avatar Kevin Whitaker

Add service and class to handle media playing.

parent 221ad0bb
set( simplecastengine_SRCS
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
KF5::Plasma
KF5::Service
KF5::I18n
)
install(TARGETS plasma_dataengine_simplecastengine DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine)
install( PROGRAMS org.eyecreate.simplecastengine.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install(TARGETS plasma_engine_simplecast DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine)
install(FILES simplecastcontrol.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services)
install(FILES plasma-dataengine-simplecast.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
/*
* 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;
}
/*
* 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
[Desktop Entry]
Name=Simple Cast Engine
Name=Simple Cast
Comment=Data Engine that handles listing, queueing, and playing media URLs from other devices.
Type=Service
Icon=document-share
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_dataengine_simplecast
X-Plasma-EngineName=simplecast
X-KDE-Library=plasma_engine_simplecast
X-Plasma-EngineName=org.eyecreate.simplecast
X-KDE-PluginInfo-Author=Kevin Whitaker
X-KDE-PluginInfo-Email=eyecreate@eyecreate.org
X-KDE-PluginInfo-Name=simplecast
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=Examples
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true
<?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 "simplecastservice.h"
SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args)
: Plasma::DataEngine(parent,args)
......@@ -29,16 +30,35 @@ SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args)
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)
{
//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
}
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"
......@@ -23,16 +23,19 @@
#include <Plasma/DataEngine>
#include <qt5/QtCore/QString>
class SimpleCastEngine : public Plasma::DataEngine
{
Q_OBJECT
public:
SimpleCastEngine(QObject *parent, const QVariantList &args);
QStringList sources() const override;
Plasma::Service *serviceForSource(const QString &source) override;
protected:
bool sourceRequestEvent(const QString &source);
bool updateSourceEvent(const QString &source);
bool sourceRequestEvent(const QString &source) override;
bool updateSourceEvent(const QString &source) override;
};
......
/*
* <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"
/*
* <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
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