Commit bf66593c authored by Scott Wheeler's avatar Scott Wheeler

DCOP is back.

svn path=/trunk/kdemultimedia/juk/; revision=304639
parent 68bc8db0
......@@ -152,7 +152,7 @@ bool ArtsPlayer::paused() const
return false;
}
long ArtsPlayer::totalTime() const
int ArtsPlayer::totalTime() const
{
if(serverRunning() && m_playobject)
return m_playobject->overallTime().seconds;
......@@ -160,7 +160,7 @@ long ArtsPlayer::totalTime() const
return -1;
}
long ArtsPlayer::currentTime() const
int ArtsPlayer::currentTime() const
{
if(serverRunning() && m_playobject &&
(m_playobject->state() == Arts::posPlaying ||
......@@ -190,7 +190,7 @@ int ArtsPlayer::position() const
// player seek functions
/////////////////////////////////////////////////////////////////////////////////
void ArtsPlayer::seek(long seekTime)
void ArtsPlayer::seek(int seekTime)
{
if(serverRunning() && m_playobject) {
Arts::poTime poSeekTime;
......
......@@ -57,11 +57,11 @@ public:
virtual bool playing() const;
virtual bool paused() const;
virtual long totalTime() const;
virtual long currentTime() const;
virtual int totalTime() const;
virtual int currentTime() const;
virtual int position() const; // in this case not really the percent
virtual void seek(long seekTime);
virtual void seek(int seekTime);
virtual void seekPosition(int position);
private slots:
......
......@@ -96,12 +96,12 @@ bool GStreamerPlayer::paused() const
return m_player->getState() == Element::STATE_PAUSED;
}
long GStreamerPlayer::totalTime() const
int GStreamerPlayer::totalTime() const
{
return m_durationNs / 1000000000L;
}
long GStreamerPlayer::currentTime() const
int GStreamerPlayer::currentTime() const
{
return m_positionNs / 1000000000L;
}
......@@ -118,7 +118,7 @@ int GStreamerPlayer::position() const
// m_player seek functions
/////////////////////////////////////////////////////////////////////////////////
void GStreamerPlayer::seek(long seekTime)
void GStreamerPlayer::seek(int seekTime)
{
// seek time in seconds?
m_player->seekToTime(seekTime*1000000000);
......
......@@ -45,11 +45,11 @@ public:
virtual bool playing() const;
virtual bool paused() const;
virtual long totalTime() const;
virtual long currentTime() const;
virtual int totalTime() const;
virtual int currentTime() const;
virtual int position() const; // in this case not really the percent
virtual void seek(long seekTime);
virtual void seek(int seekTime);
virtual void seekPosition(int position);
public slots:
......
......@@ -44,6 +44,7 @@ using namespace ActionCollection;
JuK::JuK(QWidget *parent, const char *name) :
KMainWindow(parent, name, WDestructiveClose),
DCOPObject("Collection"),
m_player(PlayerManager::instance()),
m_shuttingDown(false)
{
......
......@@ -23,9 +23,9 @@
#include <kmainwindow.h>
#include <kpopupmenu.h>
#include "playermanager.h"
#include "playlistsplitter.h"
#include "jukIface.h"
class QTimer;
class QListViewItem;
......@@ -34,7 +34,7 @@ class SliderAction;
class StatusLabel;
class SystemTray;
class JuK : public KMainWindow
class JuK : public KMainWindow, public CollectionIface
{
Q_OBJECT
......
......@@ -4,14 +4,22 @@
#include <dcopobject.h>
#include <qstringlist.h>
class JuKIface : virtual public DCOPObject
class CollectionIface : virtual public DCOPObject
{
K_DCOP
public:
CollectionIface() : DCOPObject("Collection") {}
k_dcop:
virtual void openFile(const QString &s) = 0;
virtual void openFile(const QStringList &file) = 0;
};
class PlayerIface : virtual public DCOPObject
{
K_DCOP
public:
PlayerIface() : DCOPObject("Player") {}
k_dcop:
virtual void play() = 0;
virtual void pause() = 0;
virtual void stop() = 0;
......@@ -24,13 +32,14 @@ k_dcop:
virtual void volumeUp() = 0;
virtual void volumeDown() = 0;
virtual void volumeMute() = 0;
virtual void mute() = 0;
virtual void setVolume(float volume) = 0;
virtual void setTime(int time) = 0;
virtual void startPlayingPlaylist() = 0;
virtual void seek(int time) = 0;
// virtual void startPlayingPlaylist() = 0;
virtual QString playingString() const = 0;
// virtual QString playingString() const = 0;
virtual int currentTime() const = 0;
virtual int totalTime() const = 0;
};
#endif
......@@ -38,11 +38,11 @@ public:
virtual bool playing() const = 0;
virtual bool paused() const = 0;
virtual long totalTime() const = 0;
virtual long currentTime() const = 0;
virtual int totalTime() const = 0;
virtual int currentTime() const = 0;
virtual int position() const = 0; // in this case not really the percent
virtual void seek(long seekTime) = 0;
virtual void seek(int seekTime) = 0;
virtual void seekPosition(int position) = 0;
protected:
......
......@@ -69,7 +69,8 @@ static Player *createPlayer(int system = ArtsBackend)
////////////////////////////////////////////////////////////////////////////////
PlayerManager::PlayerManager() :
QObject(0, "PlayerManager"),
Player(),
DCOPObject("Player"),
m_sliderAction(0),
m_playlistInterface(0),
m_statusLabel(0),
......@@ -121,7 +122,7 @@ float PlayerManager::volume() const
return player()->volume();
}
long PlayerManager::totalTime() const
int PlayerManager::totalTime() const
{
if(!player())
return 0;
......@@ -129,7 +130,7 @@ long PlayerManager::totalTime() const
return player()->totalTime();
}
long PlayerManager::currentTime() const
int PlayerManager::currentTime() const
{
if(!player())
return 0;
......@@ -216,6 +217,11 @@ void PlayerManager::play(const FileHandle &file)
m_timer->start(m_pollInterval);
}
void PlayerManager::play()
{
play(FileHandle::null());
}
void PlayerManager::pause()
{
if(!player())
......@@ -260,7 +266,7 @@ void PlayerManager::setVolume(float volume)
player()->setVolume(volume);
}
void PlayerManager::seek(long seekTime)
void PlayerManager::seek(int seekTime)
{
if(!player())
return;
......@@ -414,7 +420,7 @@ void PlayerManager::slotUpdateTime(int position)
float positionFraction = float(position) / m_sliderAction->trackPositionSlider()->maxValue();
float totalTime = float(player()->totalTime());
long seekTime = long(positionFraction * totalTime + 0.5); // "+0.5" for rounding
int seekTime = int(positionFraction * totalTime + 0.5); // "+0.5" for rounding
m_statusLabel->setItemCurrentTime(seekTime);
}
......
......@@ -18,21 +18,22 @@
#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H
#include "player.h"
#include "filehandle.h"
#include "jukIface.h"
class QTimer;
class KSelectAction;
class SliderAction;
class StatusLabel;
class PlaylistInterface;
class Player;
/**
* This class serves as a proxy to the Player interface and handles managing
* the actions from the top-level mainwindow.
*/
class PlayerManager : public QObject
class PlayerManager : public Player, public PlayerIface
{
Q_OBJECT
......@@ -46,8 +47,8 @@ public:
bool playing() const;
bool paused() const;
float volume() const;
long totalTime() const;
long currentTime() const;
int totalTime() const;
int currentTime() const;
int position() const;
void setPlaylistInterface(PlaylistInterface *interface);
......@@ -57,11 +58,12 @@ public:
public slots:
void play(const FileHandle &file = FileHandle::null());
void play(const FileHandle &file);
void play();
void pause();
void stop();
void setVolume(float volume = 1.0);
void seek(long seekTime);
void seek(int seekTime);
void seekPosition(int position);
void seekForward();
void seekBack();
......
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