[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bktorrent/4=2E1=5D_/=3A_Backport_to_4=2E1=3A_Fix_med?=
From: Joris <joris.guisson () gmail ! com>
Date: 2011-02-14 19:35:15
Message-ID: 20110214193515.45B64A609B () git ! kde ! org
[Download RAW message or body]
Git commit d8f65b38faed6c988dfdf85cf06d741fd8f7d7c7 by Joris.
Committed on 14/02/2011 at 20:33.
Pushed by guisson into branch '4.1'.
Backport to 4.1: Fix mediaplayer unable to stop in buffering mode when streaming
CCBUG: 266100
M +1 -0 ChangeLog
M +2 -2 plugins/mediaplayer/mediafile.cpp
M +10 -2 plugins/mediaplayer/mediafilestream.cpp
M +1 -1 plugins/mediaplayer/mediafilestream.h
M +11 -7 plugins/mediaplayer/mediaplayer.cpp
M +2 -3 plugins/mediaplayer/mediaplayer.h
M +3 -7 plugins/mediaplayer/mediaplayeractivity.cpp
M +1 -1 plugins/mediaplayer/mediaplayeractivity.h
M +14 -27 plugins/mediaplayer/videowidget.cpp
M +0 -7 plugins/mediaplayer/videowidget.h
http://commits.kde.org/ktorrent/d8f65b38faed6c988dfdf85cf06d741fd8f7d7c7
diff --git a/ChangeLog b/ChangeLog
index 6b81411..4e0dc0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
Changes in 4.1:
- Check if source files are missing before moving them (265607)
- Fix scanextender showing when they are not supposed to (259483)
+- Fix mediaplayer unable to stop in buffering mode when streaming (266100)
Changes in 4.1rc1:
- Make sure that apply button of config dialog is enabled properly when the group \
changes in the scanfolder settings
diff --git a/plugins/mediaplayer/mediafile.cpp b/plugins/mediaplayer/mediafile.cpp
index d50647d..a607440 100644
--- a/plugins/mediaplayer/mediafile.cpp
+++ b/plugins/mediaplayer/mediafile.cpp
@@ -247,8 +247,8 @@ namespace kt
if (mf && !mf->fullyAvailable())
{
MediaFileStream* stream = new MediaFileStream(mf->stream());
- QObject::connect(stream,SIGNAL(stateChanged(MediaFileStream::StreamState)),
- player,SLOT(streamStateChanged(MediaFileStream::StreamState)));
+ QObject::connect(stream,SIGNAL(stateChanged(int)),
+ player,SLOT(streamStateChanged(int)));
Phonon::MediaSource ms(stream);
ms.setAutoDelete(true);
return ms;
diff --git a/plugins/mediaplayer/mediafilestream.cpp \
b/plugins/mediaplayer/mediafilestream.cpp index 463d46a..b410bc1 100644
--- a/plugins/mediaplayer/mediafilestream.cpp
+++ b/plugins/mediaplayer/mediafilestream.cpp
@@ -27,6 +27,9 @@ using namespace bt;
namespace kt
{
+ const Uint32 MIN_AMOUNT_NEEDED = 16 * 1024;
+
+
MediaFileStream::MediaFileStream(bt::TorrentFileStream::WPtr stream, QObject* \
parent) : AbstractMediaStream(parent), stream(stream), waiting_for_data(false)
{
@@ -54,7 +57,7 @@ namespace kt
if (s)
{
qint64 left = s->size() - s->pos();
- qint64 min_amount_needed = Settings::previewSizeVideo();
+ qint64 min_amount_needed = MIN_AMOUNT_NEEDED;
if (left < min_amount_needed)
min_amount_needed = left;
@@ -90,7 +93,7 @@ namespace kt
// Make sure there is enough data buffered for smooth playback
qint64 left = s->size() - s->pos();
- qint64 min_amount_needed = Settings::previewSizeVideo();
+ qint64 min_amount_needed = MIN_AMOUNT_NEEDED;
if (left < min_amount_needed)
min_amount_needed = left;
@@ -116,6 +119,11 @@ namespace kt
Out(SYS_MPL|LOG_DEBUG) << "Not enough data available: " << s->bytesAvailable() \
<< " (need " << min_amount_needed << ")" << endl; waiting_for_data = true;
stateChanged(BUFFERING);
+
+ // Send some more data, otherwise phonon seems to get stuck
+ QByteArray data = s->read(4096);
+ if (!data.isEmpty())
+ writeData(data);
}
}
diff --git a/plugins/mediaplayer/mediafilestream.h \
b/plugins/mediaplayer/mediafilestream.h index fcaa62e..50ecbdb 100644
--- a/plugins/mediaplayer/mediafilestream.h
+++ b/plugins/mediaplayer/mediafilestream.h
@@ -58,7 +58,7 @@ namespace kt
signals:
/// Emitted when the stream state changes
- void stateChanged(MediaFileStream::StreamState state);
+ void stateChanged(int state);
private slots:
void dataReady();
diff --git a/plugins/mediaplayer/mediaplayer.cpp \
b/plugins/mediaplayer/mediaplayer.cpp index 3d8396b..09e0918 100644
--- a/plugins/mediaplayer/mediaplayer.cpp
+++ b/plugins/mediaplayer/mediaplayer.cpp
@@ -36,7 +36,7 @@ namespace kt
: QObject(parent),buffering(false),manually_paused(false)
{
media = new Phonon::MediaObject(this);
- audio = new Phonon::AudioOutput(Phonon::MusicCategory, this);
+ audio = new Phonon::AudioOutput(this);
Phonon::createPath(media,audio);
connect(media,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
@@ -83,12 +83,13 @@ namespace kt
Out(SYS_MPL|LOG_NOTICE) << "MediaPlayer: playing " << file.path() << endl;
Phonon::MediaSource ms = file.createMediaSource(this);
media->setCurrentSource(ms);
- media->play();
- history.append(file);
MediaFile::Ptr ptr = file.mediaFile();
- if (ptr && ptr->isVideo() && ms.type() == Phonon::MediaSource::Stream)
- openVideo(true);
+ if (ptr && ptr->isVideo())
+ openVideo();
+
+ history.append(file);
+ media->play();
}
}
@@ -135,6 +136,8 @@ namespace kt
media->stop();
media->clear();
}
+
+ onStateChanged(media->state(),Phonon::StoppedState);
}
MediaFileRef MediaPlayer::prev()
@@ -218,13 +221,14 @@ namespace kt
}
}
- void MediaPlayer::streamStateChanged(MediaFileStream::StreamState state)
+ void MediaPlayer::streamStateChanged(int state)
{
Out(SYS_MPL|LOG_DEBUG) << "Stream state changed: " << (state == \
MediaFileStream::BUFFERING ? "BUFFERING" : "PLAYING") << endl; if (state == \
MediaFileStream::BUFFERING) {
buffering = true;
media->pause();
+ onStateChanged(media->state(),Phonon::PlayingState);
}
else if (buffering)
{
@@ -246,7 +250,7 @@ namespace kt
void MediaPlayer::hasVideoChanged(bool hasVideo)
{
if (hasVideo)
- openVideo(false);
+ openVideo();
else
closeVideo();
}
diff --git a/plugins/mediaplayer/mediaplayer.h b/plugins/mediaplayer/mediaplayer.h
index fc9a5ea..adb1d69 100644
--- a/plugins/mediaplayer/mediaplayer.h
+++ b/plugins/mediaplayer/mediaplayer.h
@@ -80,7 +80,7 @@ namespace kt
private slots:
void onStateChanged(Phonon::State cur,Phonon::State old);
void hasVideoChanged(bool hasVideo);
- void streamStateChanged(MediaFileStream::StreamState state);
+ void streamStateChanged(int state);
signals:
/**
@@ -91,9 +91,8 @@ namespace kt
/**
* A video has been detected, create the video player window.
- * @param tab_only If true do not create the actual Phonon::VideoWidget yet
*/
- void openVideo(bool tab_only);
+ void openVideo();
/**
* Emitted when the video widget needs to be closed.
diff --git a/plugins/mediaplayer/mediaplayeractivity.cpp \
b/plugins/mediaplayer/mediaplayeractivity.cpp index 7ad640a..9b682b6 100644
--- a/plugins/mediaplayer/mediaplayeractivity.cpp
+++ b/plugins/mediaplayer/mediaplayeractivity.cpp
@@ -78,7 +78,7 @@ namespace kt
connect(core,SIGNAL(torrentAdded(bt::TorrentInterface*)),media_model,SLOT(onTorrentAdded(bt::TorrentInterface*)));
connect(core,SIGNAL(torrentRemoved(bt::TorrentInterface*)),media_model,SLOT(onTorrentRemoved(bt::TorrentInterface*)));
connect(media_player,SIGNAL(enableActions(unsigned \
int)),this,SLOT(enableActions(unsigned int)));
- connect(media_player,SIGNAL(openVideo(bool)),this,SLOT(openVideo(bool)));
+ connect(media_player,SIGNAL(openVideo()),this,SLOT(openVideo()));
connect(media_player,SIGNAL(closeVideo()),this,SLOT(closeVideo()));
connect(media_player,SIGNAL(aboutToFinish()),this,SLOT(aboutToFinishPlaying()));
connect(play_list,SIGNAL(selectionChanged(const QModelIndex \
&)),this,SLOT(onSelectionChanged(const QModelIndex&))); @@ -146,7 +146,7 @@ namespace \
kt tb->addAction(show_video_action);
}
- void MediaPlayerActivity::openVideo(bool tab_only)
+ void MediaPlayerActivity::openVideo()
{
QString path = media_player->getCurrentSource().path();
int idx = path.lastIndexOf(bt::DirSeparator());
@@ -162,8 +162,6 @@ namespace kt
tabs->setTabText(idx,path);
tabs->setCurrentIndex(idx);
tabs->setTabBarHidden(false);
- if (!tab_only)
- video->setVideoEnabled(true);
}
else
{
@@ -173,8 +171,6 @@ namespace kt
tabs->setTabToolTip(idx,i18n("Movie player"));
tabs->setCurrentIndex(idx);
tabs->setTabBarHidden(false);
- if (!tab_only)
- video->setVideoEnabled(true);
}
if (!show_video_action->isChecked())
@@ -197,7 +193,7 @@ namespace kt
void MediaPlayerActivity::showVideo(bool on)
{
if (on)
- openVideo(true);
+ openVideo();
else
closeVideo();
}
diff --git a/plugins/mediaplayer/mediaplayeractivity.h \
b/plugins/mediaplayer/mediaplayeractivity.h index 5420a81..3c56d09 100644
--- a/plugins/mediaplayer/mediaplayeractivity.h
+++ b/plugins/mediaplayer/mediaplayeractivity.h
@@ -63,7 +63,7 @@ namespace kt
void next();
void enableActions(unsigned int flags);
void onSelectionChanged(const QModelIndex & idx);
- void openVideo(bool tab_only);
+ void openVideo();
void closeVideo();
void setVideoFullScreen(bool on);
void onDoubleClicked(const MediaFileRef & file);
diff --git a/plugins/mediaplayer/videowidget.cpp \
b/plugins/mediaplayer/videowidget.cpp index 896d4fd..d60edbf 100644
--- a/plugins/mediaplayer/videowidget.cpp
+++ b/plugins/mediaplayer/videowidget.cpp
@@ -56,12 +56,9 @@ namespace kt
vlayout->setMargin(0);
vlayout->setSpacing(0);
- stack = new QStackedWidget(this);
- QLabel* fake_video = new QLabel(this);
- video = 0;
- fake_video->setAutoFillBackground(true);
- fake_video->setStyleSheet("QLabel {background-color: black}");
- stack->addWidget(fake_video);
+ video = new Phonon::VideoWidget(this);
+ Phonon::createPath(player->media0bject(),video);
+ video->installEventFilter(this);
chunk_bar = new VideoChunkBar(player->getCurrentSource(),this);
chunk_bar->setVisible(player->media0bject()->currentSource().type() == \
Phonon::MediaSource::Stream); @@ -104,7 +101,7 @@ namespace kt
chunk_bar->setFixedHeight(hlayout->sizeHint().height() * 0.75);
vlayout->addWidget(chunk_bar);
- vlayout->addWidget(stack);
+ vlayout->addWidget(video);
vlayout->addLayout(hlayout);
connect(player->media0bject(),SIGNAL(tick(qint64)),this,SLOT(timerTick(qint64)));
@@ -118,25 +115,6 @@ namespace kt
{
inhibitScreenSaver(false);
}
-
- void VideoWidget::setVideoEnabled(bool on)
- {
- if (on && !video)
- {
- video = new Phonon::VideoWidget(stack);
- int idx = stack->addWidget(video);
- stack->setCurrentIndex(idx);
- Phonon::createPath(player->media0bject(),video);
- video->installEventFilter(this);
- }
- else if (!on && video)
- {
- stack->removeWidget(video);
- video->deleteLater();
- video = 0;
- }
- }
-
void VideoWidget::play()
{
@@ -145,7 +123,16 @@ namespace kt
void VideoWidget::stop()
{
- player->media0bject()->stop();
+ Phonon::MediaObject* mo = player->media0bject();
+ if (mo->state() == Phonon::PausedState)
+ {
+ mo->seek(0);
+ mo->stop();
+ }
+ else
+ {
+ mo->stop();
+ }
}
diff --git a/plugins/mediaplayer/videowidget.h b/plugins/mediaplayer/videowidget.h
index 0be1e0f..705847a 100644
--- a/plugins/mediaplayer/videowidget.h
+++ b/plugins/mediaplayer/videowidget.h
@@ -58,12 +58,6 @@ namespace kt
*/
void setFullScreen(bool on);
- /**
- * Enable or disable the Video
- * @param on True to enable, false to disable
- */
- void setVideoEnabled(bool on);
-
protected:
virtual void mouseMoveEvent(QMouseEvent* event);
virtual bool eventFilter(QObject* dst, QEvent* event);
@@ -84,7 +78,6 @@ namespace kt
QString formatTime(qint64 cur,qint64 total);
private:
- QStackedWidget* stack;
Phonon::VideoWidget* video;
MediaPlayer* player;
Phonon::SeekSlider* slider;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic