Commit c6a982eb authored by Scott Wheeler's avatar Scott Wheeler

The playlist is working now. There are still many details that need to be

added, such as loading m3u files and handling proper sorting and insertion
to the playlist (where they differ from the tagger list), but that will
follow soon.

svn path=/trunk/kdemultimedia/juk/; revision=143690
parent 01c68e73
......@@ -293,7 +293,12 @@ DATA = $(rc_DATA)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
#>- DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
#>+ 4
KDE_DIST=leaks leaks2 leaks3 leaks4 leaks5 leaks6 leaks7 leaks8 leaks9 juk
DISTFILES= $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST)
TAR = tar
GZIP_ENV = --best
......@@ -774,7 +779,7 @@ clean-moc-classes:
-rm -f juk_meta_unload.cpp
#>+ 11
juk.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/genrelistreader.cpp $(srcdir)/genrelistlist.cpp $(srcdir)/genrelist.cpp $(srcdir)/genre.cpp $(srcdir)/player.cpp $(srcdir)/MPEGHeader.cpp $(srcdir)/filelistitem.cpp $(srcdir)/tag.cpp $(srcdir)/filelist.cpp $(srcdir)/customaction.cpp $(srcdir)/playlistwidget.cpp $(srcdir)/slideraction.cpp $(srcdir)/taggerwidget.cpp $(srcdir)/juk.cpp $(srcdir)/main.cpp juk_meta_unload.cpp slideraction.moc.cpp filelistitem.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp
juk.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/genrelistreader.cpp $(srcdir)/genrelistlist.cpp $(srcdir)/genrelist.cpp $(srcdir)/genre.cpp $(srcdir)/player.cpp $(srcdir)/MPEGHeader.cpp $(srcdir)/filelistitem.cpp $(srcdir)/tag.cpp $(srcdir)/filelist.cpp $(srcdir)/customaction.cpp $(srcdir)/playlistwidget.cpp $(srcdir)/slideraction.cpp $(srcdir)/taggerwidget.cpp $(srcdir)/juk.cpp $(srcdir)/main.cpp $(srcdir)/juk_meta_unload.cpp slideraction.moc.cpp filelistitem.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp
@echo 'creating juk.all_cpp.cpp ...'; \
rm -f juk.all_cpp.files juk.all_cpp.final; \
echo "#define KDE_USE_FINAL 1" >> juk.all_cpp.final; \
......
......@@ -18,6 +18,7 @@
#include <klocale.h>
#include <keditcl.h>
#include <kfiledialog.h>
#include <kiconloader.h>
#include <kdebug.h>
#include "juk.h"
......@@ -37,6 +38,7 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name)
JuK::~JuK()
{
saveConfig();
delete(playTimer);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -91,6 +93,9 @@ void JuK::setupLayout()
// set the slider to the proper orientation and make it stay that way
sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *)));
// playlist item activation connection
connect(playlist->getPlaylistList(), SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(playItem(QListViewItem *)));
}
void JuK::setupPlayer()
......@@ -100,6 +105,9 @@ void JuK::setupPlayer()
pauseAction->setEnabled(false);
stopAction->setEnabled(false);
playTimer=new QTimer(this);
connect(playTimer, SIGNAL(timeout()), this, SLOT(pollPlay()));
if(sliderAction && sliderAction->getTrackPositionSlider() && sliderAction->getVolumeSlider()) {
connect(sliderAction->getTrackPositionSlider(), SIGNAL(valueChanged(int)), this, SLOT(trackPositionSliderUpdate(int)));
connect(sliderAction->getTrackPositionSlider(), SIGNAL(sliderPressed()), this, SLOT(trackPositionSliderClick()));
......@@ -198,27 +206,17 @@ void JuK::removeFromPlaylist()
void JuK::playFile()
{
if(tagger && tagger->getSelectedItem()) {
// get the volume to start with
float volume = float(sliderAction->getVolumeSlider()->value()) / float(sliderAction->getVolumeSlider()->maxValue());
playTimer=new QTimer(this);
player.play(tagger->getSelectedItem()->absFilePath(), volume);
if(player.playing()) {
playAction->setEnabled(false);
pauseAction->setEnabled(true);
stopAction->setEnabled(true);
sliderAction->getTrackPositionSlider()->setEnabled(true);
connect(playTimer, SIGNAL(timeout()), this, SLOT(pollPlay()));
playTimer->start(800);
}
if(playlist) {
if(playlist->getSelectedItems()->count() > 0)
playItem(dynamic_cast<FileListItem *>(playlist->getSelectedItems()->at(0)));
else
playItem(playlist->firstItem());
}
}
void JuK::pauseFile()
{
playTimer->stop();
delete(playTimer);
player.pause();
playAction->setEnabled(true);
pauseAction->setEnabled(false);
......@@ -227,13 +225,13 @@ void JuK::pauseFile()
void JuK::stopFile()
{
playTimer->stop();
delete(playTimer);
player.stop();
playAction->setEnabled(true);
pauseAction->setEnabled(false);
stopAction->setEnabled(false);
sliderAction->getTrackPositionSlider()->setValue(0);
sliderAction->getTrackPositionSlider()->setEnabled(false);
playingItem->setPixmap(0, 0);
}
void JuK::trackPositionSliderClick()
......@@ -256,20 +254,35 @@ void JuK::trackPositionSliderUpdate(int position)
void JuK::pollPlay()
{
noSeek=true;
noSeek = true;
if(!player.playing()) {
playTimer->stop();
if(player.paused()) {
pauseFile();
}
else {
stopFile();
if(playingItem && dynamic_cast<FileListItem*>(playingItem->itemBelow())) {
playingItem->setPixmap(0, 0);
playingItem = dynamic_cast<FileListItem *>(playingItem->itemBelow());
sliderAction->getTrackPositionSlider()->setValue(0);
player.play(playingItem->absFilePath(), player.getVolume());
if(player.playing()) {
playTimer->start(pollInterval);
playingItem->setPixmap(0, QPixmap(UserIcon("playing")));
}
}
else
stopFile();
}
}
else if(!trackPositionDragging) {
// kdDebug() << player.position() << " - " << sliderAction->getTrackPositionSlider()->maxValue() << endl;
sliderAction->getTrackPositionSlider()->setValue(player.position());
}
if(player.playing() && float(player.totalTime() - player.currentTime()) < pollInterval * 2)
playTimer->changeInterval(50);
noSeek=false;
}
......@@ -282,3 +295,30 @@ void JuK::setVolume(int volume)
player.setVolume(float(volume) / float(sliderAction->getVolumeSlider()->maxValue()));
}
}
void JuK::playItem(QListViewItem *item)
{
FileListItem *fileListItem = dynamic_cast<FileListItem *>(item);
if(fileListItem)
playItem(fileListItem);
}
void JuK::playItem(FileListItem *item)
{
if(player.playing())
stopFile();
if(item) {
playingItem = item;
float volume = float(sliderAction->getVolumeSlider()->value()) / float(sliderAction->getVolumeSlider()->maxValue());
player.play(playingItem->absFilePath(), volume);
if(player.playing()) {
playAction->setEnabled(false);
pauseAction->setEnabled(true);
stopAction->setEnabled(true);
sliderAction->getTrackPositionSlider()->setEnabled(true);
playingItem->setPixmap(0, QPixmap(UserIcon("playing")));
playTimer->start(pollInterval);
}
}
}
......@@ -60,9 +60,12 @@ private:
QTimer *playTimer;
Player player;
FileListItem *playingItem;
bool trackPositionDragging;
bool noSeek;
const static int pollInterval = 800;
private slots:
// file menu
void openFile();
......@@ -88,6 +91,8 @@ private slots:
void trackPositionSliderUpdate(int position);
void pollPlay();
void setVolume(int volume);
void playItem(QListViewItem *item);
void playItem(FileListItem *item);
};
#endif
####### kdevelop will overwrite this part!!! (begin)##########
EXTRA_DIST = hi16-action-dequeue.png hi16-action-enqueue.png hi16-action-tag.png hi22-action-dequeue.png hi22-action-enqueue.png hi22-action-tag.png hi32-action-dequeue.png hi32-action-enqueue.png hi32-action-tag.png
EXTRA_DIST = hi16-action-dequeue.png hi16-action-enqueue.png hi16-action-tag.png hi22-action-dequeue.png hi22-action-enqueue.png hi22-action-tag.png hi32-action-dequeue.png hi32-action-enqueue.png hi32-action-tag.png playing.png
####### kdevelop will overwrite this part!!! (end)############
jukicondir = $(kde_datadir)/juk/icons
jukicon_ICON = AUTO
pics_DATA = playing.png
picsdir = $(kde_datadir)/juk/pics
......@@ -226,15 +226,20 @@ qt_libraries = @qt_libraries@
x_includes = @x_includes@
x_libraries = @x_libraries@
EXTRA_DIST = hi16-action-dequeue.png hi16-action-enqueue.png hi16-action-tag.png hi22-action-dequeue.png hi22-action-enqueue.png hi22-action-tag.png hi32-action-dequeue.png hi32-action-enqueue.png hi32-action-tag.png
EXTRA_DIST = hi16-action-dequeue.png hi16-action-enqueue.png hi16-action-tag.png hi22-action-dequeue.png hi22-action-enqueue.png hi22-action-tag.png hi32-action-dequeue.png hi32-action-enqueue.png hi32-action-tag.png playing.png
####### kdevelop will overwrite this part!!! (end)############
jukicondir = $(kde_datadir)/juk/icons
jukicon_ICON = AUTO
pics_DATA = playing.png
picsdir = $(kde_datadir)/juk/pics
mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DATA = $(pics_DATA)
DIST_COMMON = Makefile.am Makefile.in
......@@ -256,6 +261,25 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
install-picsDATA: $(pics_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(picsdir)
@list='$(pics_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(picsdir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(picsdir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(picsdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(picsdir)/$$p; \
fi; fi; \
done
uninstall-picsDATA:
@$(NORMAL_UNINSTALL)
list='$(pics_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(picsdir)/$$p; \
done
tags: TAGS
TAGS:
......@@ -291,23 +315,24 @@ installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
#>- install-data-am:
#>- install-data-am: install-picsDATA
#>+ 1
install-data-am: install-kde-icons
install-data-am: install-kde-icons install-picsDATA
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
#>- uninstall-am:
#>- uninstall-am: uninstall-picsDATA
#>+ 1
uninstall-am: uninstall-kde-icons
uninstall-am: uninstall-kde-icons uninstall-picsDATA
uninstall: uninstall-am
all-am: Makefile
all-am: Makefile $(DATA)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(picsdir)
mostlyclean-generic:
......@@ -340,12 +365,12 @@ maintainer-clean-am: maintainer-clean-generic distclean-am
maintainer-clean: maintainer-clean-am
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
.PHONY: uninstall-picsDATA install-picsDATA tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
......
......@@ -30,10 +30,15 @@
Player::Player()
{
// set pointers to null
server = 0;
volumeControl = 0;
media = 0;
dispatcher = 0;
// startup volume of "full" volume
currentVolume = 1.0;
setupPlayer();
}
......@@ -116,11 +121,17 @@ void Player::setVolume(float volume)
if(!volumeControl)
setupVolumeControl();
if(volumeControl) {
currentVolume = volume;
volumeControl->scaleFactor(volume);
}
}
}
float Player::getVolume()
{
return(currentVolume);
}
/////////////////////////////////////////////////////////////////////////////////
// player status functions
/////////////////////////////////////////////////////////////////////////////////
......@@ -173,7 +184,7 @@ int Player::position()
long total=media->overallTime().seconds * 1000 + media->overallTime().ms;
long current=media->currentTime().seconds * 1000 + media->currentTime().ms;
// add .5 to make rounding happen properly
return(int(double(current)*1000/total+.5)); // x1000 not x100, so this isn't an actaul percent
return(int(double(current)*1000/total+.5));
}
else {
return(-1);
......
......@@ -37,6 +37,7 @@ public:
void stop();
void setVolume(float volume = 1.0);
float getVolume();
bool playing();
bool paused();
......@@ -58,6 +59,7 @@ private:
StereoVolumeControl *volumeControl;
QString currentFile;
float currentVolume;
};
#endif
......@@ -58,6 +58,21 @@ void PlaylistWidget::add(QPtrList<QListViewItem> *items)
playlistList->append(items);
}
FileList *PlaylistWidget::getPlaylistList()
{
return(playlistList);
}
QPtrList<QListViewItem> *PlaylistWidget::getSelectedItems()
{
return(new QPtrList<QListViewItem>(playlistList->selectedItems()));
}
FileListItem *PlaylistWidget::firstItem()
{
return(dynamic_cast<FileListItem *>(playlistList->firstChild()));
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
......
......@@ -20,6 +20,8 @@
#include <klistview.h>
#include <qptrlist.h>
#include "filelist.h"
#include "filelistitem.h"
......@@ -34,6 +36,9 @@ public:
void add(FileListItem *item);
void add(QPtrList<QListViewItem> *items);
FileList *getPlaylistList();
QPtrList<QListViewItem> *getSelectedItems();
FileListItem *firstItem();
private:
void setupLayout();
......
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