aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-05-08 11:49:29 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-05-08 11:49:29 +0000
commit23c468df495bc146b78c1faca4fa5792d3cbd727 (patch)
tree9d7745118bd2efe7cbef20fd6deaf9fc46af95db
parentea7b638267352050e162334212344efe2fc8baec (diff)
downloadqmmp-23c468df495bc146b78c1faca4fa5792d3cbd727.tar.gz
qmmp-23c468df495bc146b78c1faca4fa5792d3cbd727.tar.bz2
qmmp-23c468df495bc146b78c1faca4fa5792d3cbd727.zip
display buffering progress
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@366 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/qmmp/downloader.cpp7
-rw-r--r--src/qmmp/downloader.h3
-rw-r--r--src/qmmp/soundcore.cpp6
-rw-r--r--src/qmmp/soundcore.h9
-rw-r--r--src/qmmp/streamreader.cpp3
-rw-r--r--src/qmmp/streamreader.h3
-rw-r--r--src/ui/mainwindow.cpp2
-rw-r--r--src/ui/textscroller.cpp14
-rw-r--r--src/ui/textscroller.h4
9 files changed, 42 insertions, 9 deletions
diff --git a/src/qmmp/downloader.cpp b/src/qmmp/downloader.cpp
index fe380638a..2e6d9ffd6 100644
--- a/src/qmmp/downloader.cpp
+++ b/src/qmmp/downloader.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -296,6 +296,11 @@ void Downloader::checkBuffer()
qDebug("Downloader: ready");
emit readyRead();
}
+ else if (!m_ready)
+ {
+ emit bufferingProgress(100*m_stream.buf_fill/BUFFER_SIZE);
+ qApp->processEvents();
+ }
}
diff --git a/src/qmmp/downloader.h b/src/qmmp/downloader.h
index 05175e379..ae5b13608 100644
--- a/src/qmmp/downloader.h
+++ b/src/qmmp/downloader.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -65,6 +65,7 @@ public:
signals:
void titleChanged();
void readyRead();
+ void bufferingProgress(int);
private:
qint64 readBuffer(char* data, qint64 maxlen);
diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp
index b82503535..e282f13d8 100644
--- a/src/qmmp/soundcore.cpp
+++ b/src/qmmp/soundcore.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -86,6 +86,7 @@ bool SoundCore::play(const QString &source)
if (source.left(4) == "http")
{
m_input = new StreamReader(source, this);
+ connect(m_input, SIGNAL(bufferingProgress(int)), SIGNAL(bufferingProgress(int)));
connect(m_input, SIGNAL(titleChanged(const QString&)),
SIGNAL(titleChanged(const QString&)));
connect(m_input, SIGNAL(readyRead()),SLOT(decode()));
@@ -128,7 +129,6 @@ bool SoundCore::play(const QString &source)
else
qobject_cast<StreamReader *>(m_input)->downloadFile();
return TRUE;
-
}
uint SoundCore::error()
@@ -436,5 +436,3 @@ SoundCore* SoundCore::instance()
{
return m_instance;
}
-
-
diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h
index 5bc0c8deb..37e939a12 100644
--- a/src/qmmp/soundcore.h
+++ b/src/qmmp/soundcore.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2208 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -187,6 +187,13 @@ signals:
*/
void titleChanged(const QString& title);
+ /*!
+ * This signal is emited when the stream reader fills it's buffer.
+ * The argument \b progress indicates the current percentage of buffering completed
+ */
+
+ void bufferingProgress(int progress);
+
private slots:
bool decode();
diff --git a/src/qmmp/streamreader.cpp b/src/qmmp/streamreader.cpp
index 30bb9c3a7..095181662 100644
--- a/src/qmmp/streamreader.cpp
+++ b/src/qmmp/streamreader.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -29,6 +29,7 @@ StreamReader::StreamReader(const QString &name, QObject *parent)
m_downloader = new Downloader(this, name);
connect(m_downloader, SIGNAL(titleChanged()),SLOT(updateTitle()));
connect(m_downloader, SIGNAL(readyRead()), SIGNAL(readyRead()));
+ connect(m_downloader, SIGNAL(bufferingProgress(int)), SIGNAL(bufferingProgress(int)));
}
StreamReader::~StreamReader()
diff --git a/src/qmmp/streamreader.h b/src/qmmp/streamreader.h
index c8182153a..5126be61e 100644
--- a/src/qmmp/streamreader.h
+++ b/src/qmmp/streamreader.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -65,6 +65,7 @@ public:
signals:
void titleChanged(const QString&);
void readyRead();
+ void bufferingProgress(int);
protected:
qint64 readData(char*, qint64);
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 5ae50bd5e..4de1dfd4f 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -132,6 +132,8 @@ MainWindow::MainWindow(const QStringList& args,CommandLineOptionManager* option_
SLOT(showDecoderState(const DecoderState&)));
connect(m_core, SIGNAL(titleChanged(const QString&)),
SLOT(changeTitle(const QString&)));
+ connect(m_core, SIGNAL(bufferingProgress(int)), TextScroller::getPointer(),
+ SLOT(setProgress(int)));
connect ( m_skin, SIGNAL ( skinChanged() ), this, SLOT ( updateSkin() ) );
updateEQ();
diff --git a/src/ui/textscroller.cpp b/src/ui/textscroller.cpp
index 4f3e3be80..fc12ebf12 100644
--- a/src/ui/textscroller.cpp
+++ b/src/ui/textscroller.cpp
@@ -73,6 +73,8 @@ void TextScroller::addOffset()
void TextScroller::setText(const QString& text)
{
+ if(isVisible())
+ m_timer->start();
if (m_text != text)
{
m_text = text;
@@ -103,6 +105,18 @@ void TextScroller::readSettings()
}
}
+void TextScroller::setProgress(int progress)
+{
+ m_timer->stop();
+ x = 0;
+ m_pixmap.fill ( Qt::transparent );
+ QPainter paint ( &m_pixmap );
+ paint.setPen(m_color);
+ paint.setFont(m_font);
+ paint.drawText (4,12, tr("Buffering:") + QString(" %1\%").arg(progress));
+ setPixmap(m_pixmap);
+}
+
void TextScroller::hideEvent ( QHideEvent *)
{
m_timer->stop();
diff --git a/src/ui/textscroller.h b/src/ui/textscroller.h
index 7346ce29a..67a4079db 100644
--- a/src/ui/textscroller.h
+++ b/src/ui/textscroller.h
@@ -42,6 +42,10 @@ public:
void setText(const QString&);
void readSettings();
+
+public slots:
+ void setProgress(int);
+
private slots:
void addOffset();
void updateSkin();