|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|