Replaced Phonon with QtMultimedia

preferencesAboutTextFull
Craig Watson 9 years ago
parent bedf11cc2d
commit cdb56333f3
  1. 8
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/domain/UBGraphicsItemDelegate.cpp
  3. 62
      src/domain/UBGraphicsMediaItem.cpp
  4. 23
      src/domain/UBGraphicsMediaItem.h
  5. 125
      src/domain/UBGraphicsMediaItemDelegate.cpp
  6. 20
      src/domain/UBGraphicsMediaItemDelegate.h
  7. 2
      src/domain/UBGraphicsScene.cpp

@ -1991,9 +1991,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsMed
graphicsItemToSvg(audioItem); graphicsItemToSvg(audioItem);
if (audioItem->mediaObject()->state() == Phonon::PausedState && audioItem->mediaObject()->remainingTime() > 0) if (audioItem->mediaObject()->state() == QMediaPlayer::PausedState && (audioItem->mediaObject()->duration() - audioItem->mediaObject()->position()) > 0)
{ {
qint64 pos = audioItem->mediaObject()->currentTime(); qint64 pos = audioItem->mediaObject()->position();
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos));
} }
@ -2020,9 +2020,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsMed
graphicsItemToSvg(videoItem); graphicsItemToSvg(videoItem);
if (videoItem->mediaObject()->state() == Phonon::PausedState && videoItem->mediaObject()->remainingTime() > 0) if (videoItem->mediaObject()->state() == QMediaPlayer::PausedState && (videoItem->mediaObject()->duration() - videoItem->mediaObject()->position()) > 0)
{ {
qint64 pos = videoItem->mediaObject()->currentTime(); qint64 pos = videoItem->mediaObject()->position();
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos));
} }

@ -1442,7 +1442,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
&& mDelegate->mediaObject() && mDelegate->mediaObject()->isSeekable()) && mDelegate->mediaObject() && mDelegate->mediaObject()->isSeekable())
{ {
qint64 tickPos = (mTotalTimeInMs/length)* (mouseX - minX); qint64 tickPos = (mTotalTimeInMs/length)* (mouseX - minX);
mDelegate->mediaObject()->seek(tickPos); mDelegate->mediaObject()->setPosition(tickPos);
//OSX is a bit lazy //OSX is a bit lazy
updateTicker(tickPos); updateTicker(tickPos);

@ -24,10 +24,12 @@
#include <QUrl>
#include "UBGraphicsGroupContainerItem.h" #include "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsMediaItem.h" #include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h" #include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsScene.h" #include "UBGraphicsScene.h"
#include "UBGraphicsDelegateFrame.h" #include "UBGraphicsDelegateFrame.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -49,7 +51,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{ {
update(); update();
mMediaObject = new Phonon::MediaObject(this); mMediaPlayer = new QMediaPlayer(this);
QString mediaPath = pMediaFileUrl.toString(); QString mediaPath = pMediaFileUrl.toString();
if ("" == mediaPath) if ("" == mediaPath)
@ -59,10 +61,11 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{ {
mMediaType = mediaType_Video; mMediaType = mediaType_Video;
mAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); mAudioOutput = new QAudioOutput(QAudioFormat(), this);
mMediaObject->setTickInterval(50); mMediaPlayer->setNotifyInterval(50);
mVideoWidget = new Phonon::VideoWidget(); // owned and destructed by the scene ... mVideoWidget = new QVideoWidget();
Phonon::createPath(mMediaObject, mVideoWidget);
mMediaPlayer->setVideoOutput(mVideoWidget);
if(mVideoWidget->sizeHint() == QSize(1,1)){ if(mVideoWidget->sizeHint() == QSize(1,1)){
mVideoWidget->resize(320,240); mVideoWidget->resize(320,240);
@ -74,9 +77,9 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
} }
else if (mediaPath.toLower().contains("audios")){ else if (mediaPath.toLower().contains("audios")){
mMediaType = mediaType_Audio; mMediaType = mediaType_Audio;
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); mAudioOutput = new QAudioOutput(QAudioFormat(), this);
mMediaObject->setTickInterval(1000); mMediaPlayer->setNotifyInterval(1000);
mAudioWidget = new QWidget(); mAudioWidget = new QWidget();
mAudioWidget->resize(320,26); mAudioWidget->resize(320,26);
mAudioWidget->setMinimumSize(150,26); mAudioWidget->setMinimumSize(150,26);
@ -84,15 +87,8 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
haveLinkedImage = false; haveLinkedImage = false;
} }
Phonon::createPath(mMediaObject, mAudioOutput);
mSource = Phonon::MediaSource(pMediaFileUrl);
mMediaObject->setCurrentSource(mSource);
// we should create delegate after media objects because delegate uses his properties at creation. // we should create delegate after media objects because delegate uses his properties at creation.
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject)); setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaPlayer));
// delegate should be created earler because we setWidget calls resize event for graphics proxy widgt. // delegate should be created earler because we setWidget calls resize event for graphics proxy widgt.
// resize uses delegate. // resize uses delegate.
@ -113,15 +109,18 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool))); connect(Delegate(), &UBGraphicsItemDelegate::showOnDisplayChanged,
connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool))); this, &UBGraphicsMediaItem::showOnDisplayChanged);
connect(mMediaPlayer, &QMediaPlayer::videoAvailableChanged,
this, &UBGraphicsMediaItem::hasMediaChanged);
} }
UBGraphicsMediaItem::~UBGraphicsMediaItem() UBGraphicsMediaItem::~UBGraphicsMediaItem()
{ {
if (mMediaObject) if (mMediaPlayer)
mMediaObject->stop(); mMediaPlayer->stop();
} }
@ -143,13 +142,13 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
|| (change == QGraphicsItem::ItemSceneChange) || (change == QGraphicsItem::ItemSceneChange)
|| (change == QGraphicsItem::ItemVisibleChange)) || (change == QGraphicsItem::ItemVisibleChange))
{ {
if (mMediaObject && (!isEnabled() || !isVisible() || !scene())) if (mMediaPlayer && (!isEnabled() || !isVisible() || !scene()))
mMediaObject->pause(); mMediaPlayer->pause();
} }
else if (change == QGraphicsItem::ItemSceneHasChanged) else if (change == QGraphicsItem::ItemSceneHasChanged)
{ {
if (!scene()) if (!scene())
mMediaObject->stop(); mMediaPlayer->stop();
else { else {
QString absoluteMediaFilename; QString absoluteMediaFilename;
@ -159,7 +158,7 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
absoluteMediaFilename = mMediaFileUrl.toLocalFile(); absoluteMediaFilename = mMediaFileUrl.toLocalFile();
if (absoluteMediaFilename.length() > 0) if (absoluteMediaFilename.length() > 0)
mMediaObject->setCurrentSource(Phonon::MediaSource(absoluteMediaFilename)); mMediaPlayer->setMedia(QUrl::fromLocalFile(absoluteMediaFilename));
} }
} }
@ -193,7 +192,12 @@ void UBGraphicsMediaItem::toggleMute()
void UBGraphicsMediaItem::setMute(bool bMute) void UBGraphicsMediaItem::setMute(bool bMute)
{ {
mMuted = bMute; mMuted = bMute;
mAudioOutput->setMuted(mMuted);
if (bMute)
mAudioOutput->setVolume(0);
else
mAudioOutput->setVolume(mVolume);
mMutedByUserAction = mMuted; mMutedByUserAction = mMuted;
sIsMutedByDefault = mMuted; sIsMutedByDefault = mMuted;
} }
@ -201,9 +205,9 @@ void UBGraphicsMediaItem::setMute(bool bMute)
void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia) void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia)
{ {
if(hasMedia && mMediaObject->isSeekable()) if(hasMedia && mMediaPlayer->isSeekable())
{ {
mMediaObject->seek(mInitialPos); mMediaPlayer->setPosition(mInitialPos);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate()); UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate());
if (med) if (med)
med->updateTicker(initialPos()); med->updateTicker(initialPos());
@ -220,7 +224,7 @@ UBGraphicsScene* UBGraphicsMediaItem::scene()
void UBGraphicsMediaItem::activeSceneChanged() void UBGraphicsMediaItem::activeSceneChanged()
{ {
if (UBApplication::boardController->activeScene() != scene()) if (UBApplication::boardController->activeScene() != scene())
mMediaObject->pause(); mMediaPlayer->pause();
} }
@ -229,12 +233,12 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
if (!shown) if (!shown)
{ {
mMuted = true; mMuted = true;
mAudioOutput->setMuted(mMuted); mAudioOutput->setVolume(0);
} }
else if (!mMutedByUserAction) else if (!mMutedByUserAction)
{ {
mMuted = false; mMuted = false;
mAudioOutput->setMuted(mMuted); mAudioOutput->setVolume(mVolume);
} }
} }

@ -28,10 +28,12 @@
#ifndef UBGRAPHICSMEDIAITEM_H #ifndef UBGRAPHICSMEDIAITEM_H
#define UBGRAPHICSMEDIAITEM_H #define UBGRAPHICSMEDIAITEM_H
#include <QAudioOutput>
#include <QMediaPlayer>
#include <QVideoWidget>
#include "UBGraphicsProxyWidget.h" #include "UBGraphicsProxyWidget.h"
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
@ -63,9 +65,9 @@ public:
virtual void mediaFileUrl(QUrl url){mMediaFileUrl=url;} virtual void mediaFileUrl(QUrl url){mMediaFileUrl=url;}
Phonon::MediaObject* mediaObject() const QMediaPlayer* mediaObject() const
{ {
return mMediaObject; return mMediaPlayer;
} }
void setInitialPos(qint64 p) { void setInitialPos(qint64 p) {
@ -80,7 +82,7 @@ public:
return mMuted; return mMuted;
} }
Phonon::VideoWidget* videoWidget() const QVideoWidget* videoWidget() const
{ {
return mVideoWidget; return mVideoWidget;
} }
@ -115,10 +117,10 @@ protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource(); virtual void clearSource();
Phonon::MediaObject *mMediaObject; QMediaPlayer* mMediaPlayer;
Phonon::VideoWidget *mVideoWidget; QVideoWidget* mVideoWidget;
Phonon::AudioOutput *mAudioOutput; QAudioOutput* mAudioOutput;
Phonon::MediaSource mSource;
QWidget *mAudioWidget; QWidget *mAudioWidget;
private: private:
@ -126,6 +128,7 @@ private:
bool mMuted; bool mMuted;
bool mMutedByUserAction; bool mMutedByUserAction;
static bool sIsMutedByDefault; static bool sIsMutedByDefault;
qreal mVolume;
QUrl mMediaFileUrl; QUrl mMediaFileUrl;
QString mMediaSource; QString mMediaSource;

@ -43,7 +43,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent) UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, QMediaPlayer* pMedia, QObject * parent)
: UBGraphicsItemDelegate(pDelegated, parent, GF_COMMON : UBGraphicsItemDelegate(pDelegated, parent, GF_COMMON
| GF_RESPECT_RATIO | GF_RESPECT_RATIO
| GF_TOOLBAR_USED | GF_TOOLBAR_USED
@ -56,11 +56,22 @@ UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pD
QPalette palette; QPalette palette;
palette.setBrush ( QPalette::Light, Qt::darkGray ); palette.setBrush ( QPalette::Light, Qt::darkGray );
mMedia->setTickInterval(50); mMedia->setNotifyInterval(50);
connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State)));
connect(mMedia, SIGNAL(finished()), this, SLOT(updatePlayPauseState())); connect(mMedia, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64))); this, SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus)));
connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
connect(mMedia, SIGNAL(stateChanged(QMediaPlayer::State)),
this, SLOT(mediaStateChanged(QMediaPlayer::State)));
connect(mMedia, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error),
this, &UBGraphicsMediaItemDelegate::mediaError);
connect(mMedia, SIGNAL(positionChanged(qint64)),
this, SLOT(updateTicker(qint64)));
connect(mMedia, SIGNAL(durationChanged(qint64)),
this, SLOT(totalTimeChanged(qint64)));
if (delegated()->hasLinkedImage()) if (delegated()->hasLinkedImage())
{ {
@ -95,10 +106,12 @@ void UBGraphicsMediaItemDelegate::buildButtons()
{ {
if(!mPlayPauseButton){ if(!mPlayPauseButton){
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); connect(mPlayPauseButton, SIGNAL(clicked(bool)),
this, SLOT(togglePlayPause()));
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); connect(mStopButton, SIGNAL(clicked(bool)),
mMedia, SLOT(stop()));
mMediaControl = new DelegateMediaControl(delegated(), mToolBarItem); mMediaControl = new DelegateMediaControl(delegated(), mToolBarItem);
mMediaControl->setFlag(QGraphicsItem::ItemIsSelectable, true); mMediaControl->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -109,8 +122,10 @@ void UBGraphicsMediaItemDelegate::buildButtons()
else else
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); connect(mMuteButton, SIGNAL(clicked(bool)),
connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); // for changing button image delegated(), SLOT(toggleMute()));
connect(mMuteButton, SIGNAL(clicked(bool)),
this, SLOT(toggleMute())); // for changing button image
mToolBarButtons << mPlayPauseButton << mStopButton << mMuteButton; mToolBarButtons << mPlayPauseButton << mStopButton << mMuteButton;
@ -120,10 +135,17 @@ void UBGraphicsMediaItemDelegate::buildButtons()
if (mToolBarShowTimer) if (mToolBarShowTimer)
{ {
connect(mPlayPauseButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); connect(mPlayPauseButton, SIGNAL(clicked(bool)),
connect(mStopButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); mToolBarShowTimer, SLOT(start()));
connect(mMediaControl, SIGNAL(used()), mToolBarShowTimer, SLOT(start()));
connect(mMuteButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); connect(mStopButton, SIGNAL(clicked(bool)),
mToolBarShowTimer, SLOT(start()));
connect(mMediaControl, SIGNAL(used()),
mToolBarShowTimer, SLOT(start()));
connect(mMuteButton, SIGNAL(clicked(bool)),
mToolBarShowTimer, SLOT(start()));
} }
@ -195,55 +217,82 @@ UBGraphicsMediaItem* UBGraphicsMediaItemDelegate::delegated()
return dynamic_cast<UBGraphicsMediaItem*>(mDelegated); return dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
} }
void UBGraphicsMediaItemDelegate::togglePlayPause() void UBGraphicsMediaItemDelegate::togglePlayPause()
{ {
if (delegated() && delegated()->mediaObject()) { if (delegated() && delegated()->mediaObject()) {
Phonon::MediaObject* media = delegated()->mediaObject(); QMediaPlayer * media = delegated()->mediaObject();
if (media->state() == Phonon::StoppedState) {
if (media->state() == QMediaPlayer::StoppedState)
media->play(); media->play();
} else if (media->state() == Phonon::PlayingState) {
if (media->remainingTime() <= 0) { else if (media->state() == QMediaPlayer::PlayingState) {
if ((media->duration() - media->position()) <= 0) {
media->stop(); media->stop();
media->play(); media->play();
} else { }
else {
media->pause(); media->pause();
if(delegated()->scene()) if(delegated()->scene())
delegated()->scene()->setModified(true); delegated()->scene()->setModified(true);
} }
} else if (media->state() == Phonon::PausedState) {
if (media->remainingTime() <= 0) {
media->stop();
} }
else if (media->state() == QMediaPlayer::PausedState) {
if ((media->duration() - media->position()) <= 0)
media->stop();
media->play(); media->play();
} else if ( media->state() == Phonon::LoadingState ) { }
delegated()->mediaObject()->setCurrentSource(delegated()->mediaFileUrl());
else if ( media->mediaStatus() == QMediaPlayer::LoadingMedia) {
delegated()->mediaObject()->setMedia(delegated()->mediaFileUrl());
media->play(); media->play();
} else if (media->state() == Phonon::ErrorState){
qDebug() << "Error appeared." << media->errorString();
} }
else if (media->error())
qDebug() << "Error appeared." << media->errorString();
} }
} }
void UBGraphicsMediaItemDelegate::mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate ) void UBGraphicsMediaItemDelegate::mediaStatusChanged(QMediaPlayer::MediaStatus status)
{ {
Q_UNUSED(newstate); // Possible statuses are: UnknownMediaStatus, NoMedia, LoadingMedia, LoadedMedia,
Q_UNUSED(oldstate); // StalledMedia, BufferingMedia, BufferedMedia, EndOfMedia, InvalidMedia
if (oldstate == Phonon::LoadingState) if (status == QMediaPlayer::LoadedMedia)
{ mMediaControl->totalTimeChanged(delegated()->mediaObject()->duration());
mMediaControl->totalTimeChanged(delegated()->mediaObject()->totalTime());
} // in most cases, the only necessary action is to update the play/pause state
updatePlayPauseState(); updatePlayPauseState();
} }
void UBGraphicsMediaItemDelegate::mediaStateChanged(QMediaPlayer::State state)
{
// Possible states are StoppedState, PlayingState and PausedState
// updatePlayPauseState handles this functionality
updatePlayPauseState();
}
void UBGraphicsMediaItemDelegate::mediaError(QMediaPlayer::Error error)
{
// Possible errors are NoError, ResourceError, FormatError, NetworkError, AccessDeniedError,
// ServiceMissingError
Q_UNUSED(error);
qDebug() << "Error appeared." << mMedia->errorString();
}
void UBGraphicsMediaItemDelegate::updatePlayPauseState() void UBGraphicsMediaItemDelegate::updatePlayPauseState()
{ {
Phonon::MediaObject* media = delegated()->mediaObject(); QMediaPlayer * media = delegated()->mediaObject();
if (media->state() == Phonon::PlayingState) if (media->state() == QMediaPlayer::PlayingState)
mPlayPauseButton->setFileName(":/images/pause.svg"); mPlayPauseButton->setFileName(":/images/pause.svg");
else else
mPlayPauseButton->setFileName(":/images/play.svg"); mPlayPauseButton->setFileName(":/images/play.svg");
@ -252,8 +301,8 @@ void UBGraphicsMediaItemDelegate::updatePlayPauseState()
void UBGraphicsMediaItemDelegate::updateTicker(qint64 time) void UBGraphicsMediaItemDelegate::updateTicker(qint64 time)
{ {
Phonon::MediaObject* media = delegated()->mediaObject(); QMediaPlayer* media = delegated()->mediaObject();
mMediaControl->totalTimeChanged(media->totalTime()); mMediaControl->totalTimeChanged(media->duration());
mMediaControl->updateTicker(time); mMediaControl->updateTicker(time);
} }

@ -29,8 +29,8 @@
#define UBGRAPHICSMEDIAITEMDELEGATE_H_ #define UBGRAPHICSMEDIAITEMDELEGATE_H_
#include <QtGui> #include <QtGui>
#include <phonon/MediaObject>
#include <QTimer> #include <QTimer>
#include <QtMultimedia>
#include "core/UB.h" #include "core/UB.h"
#include "UBGraphicsItemDelegate.h" #include "UBGraphicsItemDelegate.h"
@ -43,12 +43,12 @@ class UBGraphicsMediaItemDelegate : public UBGraphicsItemDelegate
Q_OBJECT Q_OBJECT
public: public:
UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent = 0); UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, QMediaPlayer* pMedia, QObject * parent = 0);
virtual ~UBGraphicsMediaItemDelegate(); virtual ~UBGraphicsMediaItemDelegate();
virtual void positionHandles(); virtual void positionHandles();
bool mousePressEvent(QGraphicsSceneMouseEvent *event); bool mousePressEvent(QGraphicsSceneMouseEvent* event);
public slots: public slots:
@ -61,14 +61,18 @@ class UBGraphicsMediaItemDelegate : public UBGraphicsItemDelegate
void togglePlayPause(); void togglePlayPause();
void mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate );
void updatePlayPauseState(); void updatePlayPauseState();
void totalTimeChanged(qint64 newTotalTime); void totalTimeChanged(qint64 newTotalTime);
void hideToolBar(); void hideToolBar();
void mediaStatusChanged(QMediaPlayer::MediaStatus status);
void mediaStateChanged(QMediaPlayer::State state);
void mediaError(QMediaPlayer::Error error);
protected: protected:
virtual void buildButtons(); virtual void buildButtons();
@ -77,11 +81,11 @@ class UBGraphicsMediaItemDelegate : public UBGraphicsItemDelegate
DelegateButton* mPlayPauseButton; DelegateButton* mPlayPauseButton;
DelegateButton* mStopButton; DelegateButton* mStopButton;
DelegateButton* mMuteButton; DelegateButton* mMuteButton;
DelegateMediaControl *mMediaControl; DelegateMediaControl* mMediaControl;
Phonon::MediaObject* mMedia; QMediaPlayer* mMedia; // mMedia belongs to the associated UBGraphicsMediaItem (mDelegated)
QTimer *mToolBarShowTimer; QTimer* mToolBarShowTimer;
int m_iToolBarShowingInterval; int m_iToolBarShowingInterval;
}; };

@ -1340,7 +1340,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
if (!shouldPlayAsap) if (!shouldPlayAsap)
{ {
mediaItem->mediaObject()->pause(); mediaItem->mediaObject()->pause();
mediaItem->mediaObject()->seek(0); mediaItem->mediaObject()->setPosition(0);
} }
setDocumentUpdated(); setDocumentUpdated();

Loading…
Cancel
Save