Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
cdb56333
Commit
cdb56333
authored
Nov 09, 2015
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced Phonon with QtMultimedia
parent
bedf11cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
91 deletions
+151
-91
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+4
-4
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+1
-1
UBGraphicsMediaItem.cpp
src/domain/UBGraphicsMediaItem.cpp
+33
-29
UBGraphicsMediaItem.h
src/domain/UBGraphicsMediaItem.h
+13
-10
UBGraphicsMediaItemDelegate.cpp
src/domain/UBGraphicsMediaItemDelegate.cpp
+87
-38
UBGraphicsMediaItemDelegate.h
src/domain/UBGraphicsMediaItemDelegate.h
+12
-8
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+1
-1
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
cdb56333
...
@@ -1991,9 +1991,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsMed
...
@@ -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
...
@@ -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
));
}
}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
cdb56333
...
@@ -1442,7 +1442,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
...
@@ -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
()
->
se
ek
(
tickPos
);
mDelegate
->
mediaObject
()
->
se
tPosition
(
tickPos
);
//OSX is a bit lazy
//OSX is a bit lazy
updateTicker
(
tickPos
);
updateTicker
(
tickPos
);
...
...
src/domain/UBGraphicsMediaItem.cpp
View file @
cdb56333
...
@@ -24,10 +24,12 @@
...
@@ -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
...
@@ -49,7 +51,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{
{
update
();
update
();
mMedia
Object
=
new
Phonon
::
MediaObject
(
this
);
mMedia
Player
=
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
...
@@ -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
...
@@ -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
);
mMedia
Object
->
setTick
Interval
(
1000
);
mMedia
Player
->
setNotify
Interval
(
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
...
@@ -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
...
@@ -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
(
mMedia
Object
)
if
(
mMedia
Player
)
mMedia
Object
->
stop
();
mMedia
Player
->
stop
();
}
}
...
@@ -143,13 +142,13 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
...
@@ -143,13 +142,13 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
||
(
change
==
QGraphicsItem
::
ItemSceneChange
)
||
(
change
==
QGraphicsItem
::
ItemSceneChange
)
||
(
change
==
QGraphicsItem
::
ItemVisibleChange
))
||
(
change
==
QGraphicsItem
::
ItemVisibleChange
))
{
{
if
(
mMedia
Object
&&
(
!
isEnabled
()
||
!
isVisible
()
||
!
scene
()))
if
(
mMedia
Player
&&
(
!
isEnabled
()
||
!
isVisible
()
||
!
scene
()))
mMedia
Object
->
pause
();
mMedia
Player
->
pause
();
}
}
else
if
(
change
==
QGraphicsItem
::
ItemSceneHasChanged
)
else
if
(
change
==
QGraphicsItem
::
ItemSceneHasChanged
)
{
{
if
(
!
scene
())
if
(
!
scene
())
mMedia
Object
->
stop
();
mMedia
Player
->
stop
();
else
{
else
{
QString
absoluteMediaFilename
;
QString
absoluteMediaFilename
;
...
@@ -159,7 +158,7 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
...
@@ -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
)
mMedia
Object
->
setCurrentSource
(
Phonon
::
MediaSourc
e
(
absoluteMediaFilename
));
mMedia
Player
->
setMedia
(
QUrl
::
fromLocalFil
e
(
absoluteMediaFilename
));
}
}
}
}
...
@@ -193,7 +192,12 @@ void UBGraphicsMediaItem::toggleMute()
...
@@ -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)
...
@@ -201,9 +205,9 @@ void UBGraphicsMediaItem::setMute(bool bMute)
void
UBGraphicsMediaItem
::
hasMediaChanged
(
bool
hasMedia
)
void
UBGraphicsMediaItem
::
hasMediaChanged
(
bool
hasMedia
)
{
{
if
(
hasMedia
&&
mMedia
Object
->
isSeekable
())
if
(
hasMedia
&&
mMedia
Player
->
isSeekable
())
{
{
mMedia
Object
->
seek
(
mInitialPos
);
mMedia
Player
->
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()
...
@@ -220,7 +224,7 @@ UBGraphicsScene* UBGraphicsMediaItem::scene()
void
UBGraphicsMediaItem
::
activeSceneChanged
()
void
UBGraphicsMediaItem
::
activeSceneChanged
()
{
{
if
(
UBApplication
::
boardController
->
activeScene
()
!=
scene
())
if
(
UBApplication
::
boardController
->
activeScene
()
!=
scene
())
mMedia
Object
->
pause
();
mMedia
Player
->
pause
();
}
}
...
@@ -229,12 +233,12 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
...
@@ -229,12 +233,12 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
if
(
!
shown
)
if
(
!
shown
)
{
{
mMuted
=
true
;
mMuted
=
true
;
mAudioOutput
->
set
Muted
(
mMuted
);
mAudioOutput
->
set
Volume
(
0
);
}
}
else
if
(
!
mMutedByUserAction
)
else
if
(
!
mMutedByUserAction
)
{
{
mMuted
=
false
;
mMuted
=
false
;
mAudioOutput
->
set
Muted
(
mMuted
);
mAudioOutput
->
set
Volume
(
mVolume
);
}
}
}
}
...
...
src/domain/UBGraphicsMediaItem.h
View file @
cdb56333
...
@@ -28,10 +28,12 @@
...
@@ -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:
...
@@ -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
mMedia
Object
;
return
mMedia
Player
;
}
}
void
setInitialPos
(
qint64
p
)
{
void
setInitialPos
(
qint64
p
)
{
...
@@ -80,7 +82,7 @@ public:
...
@@ -80,7 +82,7 @@ public:
return
mMuted
;
return
mMuted
;
}
}
Phonon
::
VideoWidget
*
videoWidget
()
const
Q
VideoWidget
*
videoWidget
()
const
{
{
return
mVideoWidget
;
return
mVideoWidget
;
}
}
...
@@ -115,10 +117,10 @@ protected:
...
@@ -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:
...
@@ -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
;
...
...
src/domain/UBGraphicsMediaItemDelegate.cpp
View file @
cdb56333
...
@@ -43,7 +43,7 @@
...
@@ -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
...
@@ -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()
...
@@ -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()
...
@@ -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()
...
@@ -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()
...
@@ -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
)
{
else
if
(
media
->
state
()
==
QMediaPlayer
::
PausedState
)
{
if
((
media
->
duration
()
-
media
->
position
())
<=
0
)
media
->
stop
();
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
::
mediaStat
eChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
void
UBGraphicsMediaItemDelegate
::
mediaStat
usChanged
(
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()
...
@@ -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
);
}
}
...
...
src/domain/UBGraphicsMediaItemDelegate.h
View file @
cdb56333
...
@@ -29,8 +29,8 @@
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
;
};
};
...
...
src/domain/UBGraphicsScene.cpp
View file @
cdb56333
...
@@ -1340,7 +1340,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
...
@@ -1340,7 +1340,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
if
(
!
shouldPlayAsap
)
if
(
!
shouldPlayAsap
)
{
{
mediaItem
->
mediaObject
()
->
pause
();
mediaItem
->
mediaObject
()
->
pause
();
mediaItem
->
mediaObject
()
->
se
ek
(
0
);
mediaItem
->
mediaObject
()
->
se
tPosition
(
0
);
}
}
setDocumentUpdated
();
setDocumentUpdated
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment