on stop the video widget show a screen shot instead of the phonon::mediawidget

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 8957a360f1
commit 6cafdcfcff
  1. 98
      src/customWidgets/UBMediaWidget.cpp
  2. 12
      src/customWidgets/UBMediaWidget.h

@ -26,6 +26,8 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
, mpMediaObject(NULL) , mpMediaObject(NULL)
, mpVideoWidget(NULL) , mpVideoWidget(NULL)
, mpAudioOutput(NULL) , mpAudioOutput(NULL)
, mpLayout(NULL)
, mpSeekerLayout(NULL)
, mpPlayStopButton(NULL) , mpPlayStopButton(NULL)
, mpPauseButton(NULL) , mpPauseButton(NULL)
, mpSlider(NULL) , mpSlider(NULL)
@ -33,15 +35,16 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
, mGeneratingThumbnail(false) , mGeneratingThumbnail(false)
, mBorder(5) , mBorder(5)
, mpMediaContainer(NULL) , mpMediaContainer(NULL)
, mMediaLayout(NULL)
, mpCover(NULL) , mpCover(NULL)
// , mpVideoStackedWidget(NULL) , mpSnapshotVideoWidget(NULL)
// , mpSnapshotVideoWidget(NULL)
{ {
SET_STYLE_SHEET(); SET_STYLE_SHEET();
addAction(eAction_Close); addAction(eAction_Close);
mType = type; mType = type;
setLayout(&mLayout); mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpPlayStopButton = new UBMediaButton(this); mpPlayStopButton = new UBMediaButton(this);
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
@ -53,10 +56,11 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
mpSlider->setMinimum(0); mpSlider->setMinimum(0);
mpSlider->setMaximum(0); mpSlider->setMaximum(0);
mSeekerLayout.addWidget(mpPlayStopButton, 0); mpSeekerLayout = new QHBoxLayout(this);
mSeekerLayout.addWidget(mpPauseButton, 0); mpSeekerLayout->addWidget(mpPlayStopButton, 0);
mSeekerLayout.addWidget(mpSlider, 1); mpSeekerLayout->addWidget(mpPauseButton, 0);
mSeekerLayout.setContentsMargins(0, 0, 0, 0); mpSeekerLayout->addWidget(mpSlider, 1);
mpSeekerLayout->setContentsMargins(0, 0, 0, 0);
connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked()));
connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked()));
@ -74,10 +78,13 @@ UBMediaWidget::~UBMediaWidget()
DELETEPTR(mpPlayStopButton); DELETEPTR(mpPlayStopButton);
DELETEPTR(mpAudioOutput); DELETEPTR(mpAudioOutput);
DELETEPTR(mpVideoWidget); DELETEPTR(mpVideoWidget);
// DELETEPTR(mpVideoStackedWidget);
// DELETEPTR(mpSnapshotVideoWidget);
DELETEPTR(mpMediaObject); DELETEPTR(mpMediaObject);
DELETEPTR(mpCover); DELETEPTR(mpCover);
DELETEPTR(mpSnapshotVideoWidget);
DELETEPTR(mpVideoStackedWidget);
DELETEPTR(mpMediaContainer);
DELETEPTR(mpSeekerLayout);
DELETEPTR(mpLayout);
} }
/** /**
@ -109,10 +116,14 @@ eMediaType UBMediaWidget::mediaType()
void UBMediaWidget::showEvent(QShowEvent* event) void UBMediaWidget::showEvent(QShowEvent* event)
{ {
if(!mpVideoWidget){ if(!mpVideoWidget){
mpSnapshotVideoWidget = new QLabel(this);
mpVideoWidget = new Phonon::VideoWidget(this); mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1); mpVideoStackedWidget = new QStackedWidget(this);
mMediaLayout.addWidget(mpVideoWidget, 0); mpVideoStackedWidget->addWidget(mpVideoWidget);
mMediaLayout.addStretch(1); mpVideoStackedWidget->addWidget(mpSnapshotVideoWidget);
mMediaLayout->addStretch(1);
mMediaLayout->addWidget(mpVideoStackedWidget,0);
mMediaLayout->addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget); Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo(); adaptSizeToVideo();
mpMediaObject->play(); mpMediaObject->play();
@ -135,41 +146,39 @@ void UBMediaWidget::createMediaPlayer()
{ {
mpMediaContainer = new QWidget(this); mpMediaContainer = new QWidget(this);
mpMediaContainer->setObjectName("UBMediaVideoContainer"); mpMediaContainer->setObjectName("UBMediaVideoContainer");
mpMediaContainer->setLayout(&mMediaLayout); mMediaLayout = new QHBoxLayout(this);
mpMediaContainer->setLayout(mMediaLayout);
if(eMediaType_Video == mType){ if(eMediaType_Video == mType){
mMediaLayout.setContentsMargins(10, 10, 10, 10); mMediaLayout->setContentsMargins(10, 10, 10, 10);
if(isVisible()){ if(isVisible()){
mpSnapshotVideoWidget = new QLabel(this);
mpVideoWidget = new Phonon::VideoWidget(this); mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1); mpVideoStackedWidget = new QStackedWidget(this);
mpVideoStackedWidget->addWidget(mpVideoWidget);
// mpVideoStackedWidget = new QStackedWidget(this); mpVideoStackedWidget->addWidget(mpSnapshotVideoWidget);
// mpVideoStackedWidget->addWidget(mpVideoWidget); mMediaLayout->addStretch(1);
// mpSnapshotVideoWidget = new QLabel(this); mMediaLayout->addWidget(mpVideoStackedWidget, 0);
// mpVideoStackedWidget->addWidget(mpSnapshotVideoWidget); mMediaLayout->addStretch(1);
// mMediaLayout.addWidget(mpVideoStackedWidget,0);
mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget); Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo(); adaptSizeToVideo();
} }
mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput); Phonon::createPath(mpMediaObject, mpAudioOutput);
}else if(eMediaType_Audio == mType){ }else if(eMediaType_Audio == mType){
mMediaLayout.setContentsMargins(10, 10, 10, 10); mMediaLayout->setContentsMargins(10, 10, 10, 10);
mpCover = new QLabel(mpMediaContainer); mpCover = new QLabel(mpMediaContainer);
mpMediaContainer->setStyleSheet(QString("background: none;")); mpMediaContainer->setStyleSheet(QString("background: none;"));
setAudioCover(":images/libpalette/soundIcon.svg"); setAudioCover(":images/libpalette/soundIcon.svg");
mpCover->setScaledContents(true); mpCover->setScaledContents(true);
mMediaLayout.addStretch(1); mMediaLayout->addStretch(1);
mMediaLayout.addWidget(mpCover, 0); mMediaLayout->addWidget(mpCover, 0);
mMediaLayout.addStretch(1); mMediaLayout->addStretch(1);
mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput); Phonon::createPath(mpMediaObject, mpAudioOutput);
} }
mLayout.addWidget(mpMediaContainer, 1); mpLayout->addWidget(mpMediaContainer, 1);
mLayout.addLayout(&mSeekerLayout, 0); mpLayout->addLayout(mpSeekerLayout, 0);
setActionsParent(mpMediaContainer); setActionsParent(mpMediaContainer);
} }
@ -188,21 +197,19 @@ void UBMediaWidget::adaptSizeToVideo()
} }
} }
//void UBMediaWidget::updateView(Phonon::State nextState) void UBMediaWidget::updateView(Phonon::State nextState)
//{ {
// if(eMediaType_Video == mType){ if(eMediaType_Video == mType){
// if(nextState != Phonon::PlayingState){ if(nextState != Phonon::PlayingState){
// const QPixmap& snapshot = QPixmap::grabWindow(mpVideoWidget->winId()); const QPixmap& snapshot = QPixmap::grabWindow(mpVideoWidget->winId());
// if(snapshot.size().width()!= 0){ mpSnapshotVideoWidget->setPixmap(snapshot);
// mpSnapshotVideoWidget->setPixmap(snapshot); mpVideoStackedWidget->setCurrentWidget(mpSnapshotVideoWidget);
// mpVideoStackedWidget->setCurrentWidget(mpSnapshotVideoWidget); }
// } else
// } mpVideoStackedWidget->setCurrentWidget(mpVideoWidget);
// else }
// mpVideoStackedWidget->setCurrentWidget(mpVideoWidget);
// }
//} }
/** /**
* \brief Handle the media state change notification * \brief Handle the media state change notification
@ -232,7 +239,8 @@ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldStat
mpPauseButton->setEnabled(false); mpPauseButton->setEnabled(false);
mpSlider->setValue(0); mpSlider->setValue(0);
} }
//updateView(newState); if(mType == eMediaType_Video)
updateView(newState);
} }
} }

@ -91,7 +91,7 @@ private slots:
private: private:
void createMediaPlayer(); void createMediaPlayer();
void adaptSizeToVideo(); void adaptSizeToVideo();
// void updateView(Phonon::State nextState); void updateView(Phonon::State nextState);
/** The current media type */ /** The current media type */
eMediaType mType; eMediaType mType;
@ -102,9 +102,9 @@ private:
/** The audio renderer */ /** The audio renderer */
Phonon::AudioOutput* mpAudioOutput; Phonon::AudioOutput* mpAudioOutput;
/** The principal layout of this widget */ /** The principal layout of this widget */
QVBoxLayout mLayout; QVBoxLayout* mpLayout;
/** The seeker layout */ /** The seeker layout */
QHBoxLayout mSeekerLayout; QHBoxLayout* mpSeekerLayout;
/** The play-stop button */ /** The play-stop button */
UBMediaButton* mpPlayStopButton; UBMediaButton* mpPlayStopButton;
/** The pause button */ /** The pause button */
@ -120,14 +120,14 @@ private:
/** A widget that will contain the media */ /** A widget that will contain the media */
QWidget* mpMediaContainer; QWidget* mpMediaContainer;
/** The media layout */ /** The media layout */
QHBoxLayout mMediaLayout; QHBoxLayout* mMediaLayout;
/** The audio cover */ /** The audio cover */
QLabel* mpCover; QLabel* mpCover;
/** The media url */ /** The media url */
QString mUrl; QString mUrl;
// QStackedWidget* mpVideoStackedWidget; QStackedWidget* mpVideoStackedWidget;
// QLabel* mpSnapshotVideoWidget; QLabel* mpSnapshotVideoWidget;
}; };
#endif // UBMEDIAWIDGET_H #endif // UBMEDIAWIDGET_H

Loading…
Cancel
Save