Finish implementing basic play, engine, and service.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* <one line to give the program's name and a brief idea of what it does.>
|
||||
* Copyright (C) 2019 <copyright holder> <email>
|
||||
* 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
|
||||
@@ -17,8 +16,42 @@
|
||||
*/
|
||||
|
||||
#include "simplecastservice.h"
|
||||
#include <Plasma/ServiceJob>
|
||||
|
||||
SimpleCastService::SimpleCastService(const QString &destination, QObject *parent) : Plasma::Service(parent)
|
||||
class SimpleCastJob : public Plasma::ServiceJob
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleCastJob(const QString& destination, const QString& operation, MiniMediaPlayer *player, const QVariantMap& parameters, QObject* parent = 0) : Plasma::ServiceJob(destination,operation,parameters,parent),player(player) {}
|
||||
|
||||
virtual void start() override
|
||||
{
|
||||
const auto operation = operationName();
|
||||
const auto paramaters = parameters();
|
||||
if(operation == "changePlayState")
|
||||
{
|
||||
if(paramaters.contains("playing"))
|
||||
{
|
||||
setResult(player->playPauseTrack(paramaters["playing"].toBool()));
|
||||
}
|
||||
}
|
||||
else if(operation == "skipToNextTrack")
|
||||
{
|
||||
setResult(player->nextTrack());
|
||||
}
|
||||
else if(operation == "addURLToPlaylist")
|
||||
{
|
||||
if(paramaters.contains("URL"))
|
||||
{
|
||||
setResult(player->addURLToPlaylist(paramaters["URL"].toUrl()));
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
MiniMediaPlayer *player;
|
||||
};
|
||||
|
||||
SimpleCastService::SimpleCastService(const QString &destination,MiniMediaPlayer *player, QObject *parent) : Plasma::Service(parent), player(player)
|
||||
{
|
||||
setName("simplecastcontrol");
|
||||
}
|
||||
@@ -30,7 +63,7 @@ SimpleCastService::~SimpleCastService()
|
||||
|
||||
Plasma::ServiceJob* SimpleCastService::createJob(const QString& operation, QVariantMap& parameters)
|
||||
{
|
||||
return NULL; //TODO
|
||||
return new SimpleCastJob(destination(),operation,player,parameters,this);
|
||||
}
|
||||
|
||||
//K_EXPORT_PLASMA_SERVICE(org.eyecreate.simplecast, SimpleCastService)
|
||||
|
||||
Reference in New Issue
Block a user