Commit 3ee5cdb7 authored by Matthias Kretz's avatar Matthias Kretz
Browse files

- compile agains trunk except for the systray breakage

- deprecated -= a_lot
- Player interface is not needed anymore use Phonon directly and make use of
  the tick and finished signals (no polling with QTimer anymore)
  -> the change is untested because of the systray compilation error

svn path=/branches/work/bleedingedge/kdemultimedia/juk/; revision=560481
parent da012b3d
......@@ -41,7 +41,6 @@ set(juk_SRCS searchadaptor.cpp collectionadaptor.cpp playeradaptor.cpp
musicbrainzquery.cpp
nowplaying.cpp
playermanager.cpp
player.cpp
playlist.cpp
playlistbox.cpp
playlistcollection.cpp
......@@ -116,122 +115,3 @@ install( FILES jukui.rc jukui-rtl.rc DESTINATION ${DATA_INSTALL_DIR}/juk )
install( FILES jukservicemenu.desktop DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus )
kde4_install_icons( ${ICON_INSTALL_DIR} hicolor )
#original Makefile.am contents follow:
#bin_PROGRAMS = juk
#check_PROGRAMS = tagguessertest
#
#juk_SOURCES = \
# advancedsearchdialog.cpp \
# actioncollection.cpp \
# akodeplayer.cpp \
# artsplayer.cpp \
# cache.cpp \
# categoryreaderinterface.cpp \
# collectionlist.cpp \
# coverdialog.cpp \
# coverdialogbase.ui \
# covericonview.cpp \
# coverinfo.cpp \
# covermanager.cpp \
# deletedialog.cpp \
# deletedialogbase.ui \
# directorylist.cpp \
# directorylistbase.ui \
# dynamicplaylist.cpp \
# exampleoptions.cpp \
# exampleoptionsbase.ui \
# folderplaylist.cpp \
# filehandle.cpp \
# filerenamer.cpp \
# filerenamerbase.ui \
# filerenameroptions.cpp \
# filerenameroptionsbase.ui \
# filerenamerconfigdlg.cpp \
# gstreamerplayer.cpp \
# googlefetcher.cpp \
# googlefetcherdialog.cpp \
# historyplaylist.cpp \
# juk.cpp \
# jukIface.skel \
# k3bexporter.cpp \
# keydialog.cpp \
# main.cpp \
# mediafiles.cpp \
# musicbrainzquery.cpp \
# nowplaying.cpp \
# playermanager.cpp \
# playlist.cpp \
# playlistbox.cpp \
# playlistcollection.cpp \
# playlistinterface.cpp \
# playlistitem.cpp \
# playlistsearch.cpp \
# playlistsplitter.cpp \
# searchplaylist.cpp \
# searchwidget.cpp \
# slideraction.cpp \
# sortedstringlist.cpp \
# splashscreen.cpp \
# statuslabel.cpp \
# stringshare.cpp \
# systemtray.cpp \
# tag.cpp \
# tageditor.cpp \
# tagguesser.cpp \
# tagguesserconfigdlg.cpp \
# tagguesserconfigdlgwidget.ui \
# tagrenameroptions.cpp \
# tagtransactionmanager.cpp \
# trackpickerdialog.cpp \
# trackpickerdialogbase.ui \
# tracksequenceiterator.cpp \
# tracksequencemanager.cpp \
# treeviewitemplaylist.cpp \
# upcomingplaylist.cpp \
# ktrm.cpp \
# viewmode.cpp
#
#tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp
#
#INCLUDES= $(all_includes) $(taglib_includes) $(akode_includes) $(GST_CFLAGS) $(ARTS_CFLAGS)
#
###################################################
## check to see if MusicBrainz is available
###################################################
#if link_lib_TP
#tplibs = -ltunepimp
#endif
###################################################
#
#juk_LDADD = -lm $(LDADD_GST) $(tplibs) $(LIB_KIO) $(taglib_libs) $(akode_libs) $(LIB_KHTML) $(LIB_ARTS)
#juk_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LDFLAGS_GST)
#
#KDE_CXXFLAGS = $(USE_EXCEPTIONS)
#
#tagguessertest_LDADD = $(LIB_KDECORE)
#tagguessertest_LDFLAGS = $(all_libraries)
#
#SUBDIRS = pics
#
#rcdir = $(kde_datadir)/juk
#rc_DATA = jukui.rc jukui-rtl.rc
#
#servicemenudir = $(kde_datadir)/konqueror/servicemenus
#servicemenu_DATA = jukservicemenu.desktop
#
#METASOURCES = AUTO
#KDE_ICON = AUTO
#POFILES = AUTO
#
#xdg_apps_DATA = juk.desktop
#
#messages: rc.cpp
# $(EXTRACTRC) *.rc >> rc.cpp
# $(XGETTEXT) *.rc *.cpp *.h -o $(podir)/juk.pot
# -rm rc.cpp
#KDE_OPTIONS=nofinal
......@@ -51,7 +51,7 @@ using namespace ActionCollection;
////////////////////////////////////////////////////////////////////////////////
JuK::JuK(QWidget *parent, const char *name) :
KMainWindow(parent, name, Qt::WDestructiveClose),
KMainWindow(parent, Qt::WDestructiveClose),
m_player(PlayerManager::instance()),
m_shuttingDown(false)
{
......@@ -67,7 +67,7 @@ JuK::JuK(QWidget *parent, const char *name) :
setupActions();
setupLayout();
if(QApplication::reverseLayout())
if(QApplication::isRightToLeft())
setupGUI(ToolBar | Save | Create, "jukui-rtl.rc");
else
setupGUI(ToolBar | Save | Create);
......@@ -328,7 +328,7 @@ void JuK::readConfig()
KConfigGroup playerConfig(KGlobal::config(), "Player");
if(m_sliderAction->volumeSlider()) {
int maxVolume = m_sliderAction->volumeSlider()->maxValue();
int maxVolume = m_sliderAction->volumeSlider()->maximum();
int volume = playerConfig.readEntry("Volume", maxVolume);
m_sliderAction->volumeSlider()->setVolume(volume);
}
......
......@@ -21,6 +21,7 @@
#include "mediafiles.h"
#include <taglib/tag.h>
#include <kurl.h>
#if (TAGLIB_MAJOR_VERSION>1) || \
((TAGLIB_MAJOR_VERSION==1) && (TAGLIB_MINOR_VERSION>=2))
#define TAGLIB_1_2
......@@ -47,7 +48,7 @@ namespace MediaFiles {
QStringList MediaFiles::openDialog(QWidget *parent)
{
KFileDialog dialog(QString::null, QString::null, parent);
KFileDialog dialog(KUrl(), QString::null, parent);
dialog.setOperationMode(KFileDialog::Opening);
dialog.setCaption(i18n("Open"));
......
/* This file is part of the KDE project
Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "player.h"
#include <phonon/mediaobject.h>
#include <phonon/audiopath.h>
#include <phonon/audiooutput.h>
Player::Player( QObject* parent )
: QObject( parent )
, m_media( new Phonon::MediaObject( this ) )
, m_path( new Phonon::AudioPath( this ) )
, m_output( new Phonon::AudioOutput( this ) )
{
m_output->setCategory( Phonon::MusicCategory );
m_path->addOutput( m_output );
m_media->addAudioPath( m_path );
}
Player::~Player()
{
}
void Player::play( const FileHandle &file )
{
if( file.isNull() )
return;
m_media->setUrl( KUrl::fromPath( file.absFilePath() ) );
m_media->play();
}
void Player::pause()
{
m_media->pause();
}
void Player::stop()
{
m_media->stop();
}
void Player::setVolume( float volume )
{
m_output->setVolume( volume );
}
float Player::volume() const
{
return m_output->volume();
}
bool Player::playing() const
{
return m_media->state() == Phonon::PlayingState;
}
bool Player::paused() const
{
return m_media->state() == Phonon::PausedState;
}
int Player::totalTime() const
{
return m_media->totalTime() / 1000;
}
int Player::currentTime() const
{
return m_media->currentTime() / 1000;
}
int Player::position() const
{
if( m_media->currentTime() > 0 )
return static_cast<int>( m_media->currentTime() / 1000.0f / m_media->totalTime() + 0.5f );
return -1;
}
void Player::seek( int seekTime )
{
m_media->seek( seekTime * 1000 );
}
void Player::seekPosition( int position )
{
m_media->seek( static_cast<long>( m_media->totalTime() / 1000.0f * position + 0.5f ) );
}
#include "player.moc"
// vim: sw=4 ts=4 noet
/***************************************************************************
begin : Sun Feb 17 2002
copyright : (C) 2002 - 2004 by Scott Wheeler
email : wheeler@kde.org
(C) 2006 Matthias Kretz <kretz@kde.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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include "filehandle.h"
namespace Phonon
{
class MediaObject;
class AudioPath;
class AudioOutput;
}
class Player : public QObject
{
Q_OBJECT
public:
Player( QObject* parent = 0 );
~Player();
void play(const FileHandle &file = FileHandle::null());
void pause();
void stop();
void setVolume( float volume = 1.0 );
float volume() const;
bool playing() const;
bool paused() const;
int totalTime() const;
int currentTime() const;
int position() const; // in this case not really the percent
void seek( int seekTime );
void seekPosition( int position );
private:
Phonon::MediaObject* m_media;
Phonon::AudioPath* m_path;
Phonon::AudioOutput* m_output;
};
#endif
// vim: set et sw=4 tw=0 sta:
......@@ -25,8 +25,11 @@
#include <kdebug.h>
#include <klocale.h>
#include <phonon/mediaobject.h>
#include <phonon/audiopath.h>
#include <phonon/audiooutput.h>
#include <qslider.h>
#include <QTimer>
//Added by qt3to4:
#include <QPixmap>
#include <ktoggleaction.h>
......@@ -57,15 +60,16 @@ enum PlayerManagerStatus { StatusStopped = -1, StatusPaused = 1, StatusPlaying =
////////////////////////////////////////////////////////////////////////////////
PlayerManager::PlayerManager() :
Player(),
QObject(),
m_sliderAction(0),
m_playlistInterface(0),
m_statusLabel(0),
m_player(0),
m_timer(0),
m_noSeek(false),
m_muted(false),
m_setup(false)
m_setup(false),
m_output(0),
m_audioPath(0),
m_media(0)
{
// This class is the first thing constructed during program startup, and
// therefore has no access to the widgets needed by the setup() method.
......@@ -79,7 +83,6 @@ PlayerManager::PlayerManager() :
PlayerManager::~PlayerManager()
{
delete m_player;
}
////////////////////////////////////////////////////////////////////////////////
......@@ -94,37 +97,37 @@ PlayerManager *PlayerManager::instance() // static
bool PlayerManager::playing() const
{
if(!player())
if(!m_media)
return false;
return player()->playing();
return m_media->state() == Phonon::PlayingState;
}
bool PlayerManager::paused() const
{
if(!player())
if(!m_media)
return false;
return player()->paused();
return m_media->state() == Phonon::PausedState;
}
float PlayerManager::volume() const
{
if(!player())
if(!m_output)
return 0;
return player()->volume();
return m_output->volume();
}
int PlayerManager::status() const
{
if(!player())
if(!m_media)
return StatusStopped;
if(player()->paused())
if(paused())
return StatusPaused;
if(player()->playing())
if(playing())
return StatusPlaying;
return 0;
......@@ -132,26 +135,29 @@ int PlayerManager::status() const
int PlayerManager::totalTime() const
{
if(!player())
if(!m_media)
return 0;
return player()->totalTime();
return m_media->totalTime() / 1000;
}
int PlayerManager::currentTime() const
{
if(!player())
if(!m_media)
return 0;
return player()->currentTime();
return m_media->currentTime() / 1000;
}
int PlayerManager::position() const
{
if(!player())
if(!m_media)
return 0;
return player()->position();
long curr = m_media->currentTime();
if( curr > 0 )
return static_cast<int>( curr / 1000.0f / m_media->totalTime() + 0.5f );
return -1;
}
QStringList PlayerManager::trackProperties()
......@@ -172,9 +178,9 @@ QPixmap PlayerManager::trackCover(const QString &size) const
if(!playing() && !paused())
return QPixmap();
if(size.lower() == "small")
if(size.toLower() == "small")
return m_file.coverInfo()->pixmap(CoverInfo::Thumbnail);
if(size.lower() == "large")
if(size.toLower() == "large")
return m_file.coverInfo()->pixmap(CoverInfo::FullSize);
return QPixmap();
......@@ -213,33 +219,40 @@ void PlayerManager::setStatusLabel(StatusLabel *label)
void PlayerManager::play(const FileHandle &file)
{
if(!player() || !m_playlistInterface)
if(!m_media)
setup();
if(!m_media || !m_playlistInterface)
return;
if(file.isNull()) {
if(player()->paused())
player()->play();
else if(player()->playing()) {
if(paused())
m_media->play();
else if(playing()) {
if(m_sliderAction->trackPositionSlider())
m_sliderAction->trackPositionSlider()->setValue(0);
player()->seekPosition(0);
m_media->seek(0);
}
else {
m_playlistInterface->playNext();
m_file = m_playlistInterface->currentFile();
if(!m_file.isNull())
player()->play(m_file);
{
m_media->setUrl(KUrl::fromPath(m_file.absFilePath()));
m_media->play();
}
}
}
else {
m_file = file;
player()->play(file);
m_media->setUrl(KUrl::fromPath(m_file.absFilePath()));
m_media->play();
}
// Make sure that the player() actually starts before doing anything.
if(!player()->playing()) {
if(!playing()) {
kWarning(65432) << "Unable to play " << file.absFilePath() << endl;
stop();
return;
......@@ -255,8 +268,6 @@ void PlayerManager::play(const FileHandle &file)
if(m_sliderAction->trackPositionSlider())
m_sliderAction->trackPositionSlider()->setEnabled(true);
m_timer->start(m_pollInterval);
emit signalPlay();
}
......@@ -276,29 +287,26 @@ void PlayerManager::play()
void PlayerManager::pause()
{
if(!player())
if(!m_media)
return;
if(player()->paused()) {
if(paused()) {
play();
return;
}
m_timer->stop();
action("pause")->setEnabled(false);
player()->pause();
m_media->pause();
emit signalPause();
}
void PlayerManager::stop()
{
if(!player() || !m_playlistInterface)
if(!m_media || !m_playlistInterface)
return;
m_timer->stop();
action("pause")->setEnabled(false);
action("stop")->setEnabled(false);
action("back")->setEnabled(false);
......@@ -310,7 +318,7 @@ void PlayerManager::stop()
m_sliderAction->trackPositionSlider()->setEnabled(false);
}
player()->stop();
m_media->stop();
m_playlistInterface->stop();
m_file = FileHandle::null();
......@@ -320,30 +328,29 @@ void PlayerManager::stop()
void PlayerManager::setVolume(float volume)
{
if(!player())
return;
player()->setVolume(volume);
if(!m_output)
setup();
m_output->setVolume(volume);
}
void PlayerManager::seek(int seekTime)
{
if(!player())
if(!m_media)
return;
player()->seek(seekTime);
m_media->seek(seekTime);
}
void PlayerManager::seekPosition(int position)
{
if(!player())
if(!m_media)
return;
if(!player()->playing() || m_noSeek)
if(!playing() || m_noSeek)
return;
slotUpdateTime(position);
player()->seekPosition(position);
m_media->seek( static_cast<long>( m_media->totalTime() / 1000.0f * position + 0.5f ) );
if(m_sliderAction->trackPositionSlider())
m_sliderAction->trackPositionSlider()->setValue(position);
......@@ -388,11 +395,11 @@ void PlayerManager::back()
void PlayerManager::volumeUp()
{
if(!player() || !m_sliderAction || !m_sliderAction->volumeSlider())
if(!m_media || !m_sliderAction || !m_sliderAction->volumeSlider())
return;
int volume = m_sliderAction->volumeSlider()->volume() +
m_sliderAction->volumeSlider()->maxValue() / 25; // 4% up
m_sliderAction->volumeSlider()->maximum() / 25; // 4% up
slotSetVolume(volume);
m_sliderAction->volumeSlider()->setVolume(volume);
......@@ -400,11 +407,11 @@ void PlayerManager::volumeUp()
void PlayerManager::volumeDown()
{
if(!player() || !m_sliderAction || !m_sliderAction->volumeSlider())
if(!m_media || !m_sliderAction || !m_sliderAction->volumeS