@ -68,6 +68,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
, mMuted ( sIsMutedByDefault )
, mMuted ( sIsMutedByDefault )
, mMutedByUserAction ( sIsMutedByDefault )
, mMutedByUserAction ( sIsMutedByDefault )
, mStopped ( false )
, mStopped ( false )
, mFirstLoad ( true )
, mMediaFileUrl ( pMediaFileUrl )
, mMediaFileUrl ( pMediaFileUrl )
, mLinkedImage ( NULL )
, mLinkedImage ( NULL )
, mInitialPos ( 0 )
, mInitialPos ( 0 )
@ -135,8 +136,8 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
* active scene has changed , or when the item is first created .
* active scene has changed , or when the item is first created .
* If and when Qt fix this issue , this should be changed back .
* If and when Qt fix this issue , this should be changed back .
* */
* */
//mMediaObject->setVideoOutput(mVideoItem);
mMediaObject - > setVideoOutput ( mVideoItem ) ;
mHasVideoOutput = fals e;
mHasVideoOutput = tru e;
mMediaObject - > setNotifyInterval ( 50 ) ;
mMediaObject - > setNotifyInterval ( 50 ) ;
@ -175,12 +176,12 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
| | ( change = = QGraphicsItem : : ItemVisibleChange ) )
| | ( change = = QGraphicsItem : : ItemVisibleChange ) )
{
{
if ( mMediaObject & & ( ! isEnabled ( ) | | ! isVisible ( ) | | ! scene ( ) ) )
if ( mMediaObject & & ( ! isEnabled ( ) | | ! isVisible ( ) | | ! scene ( ) ) )
mMediaObject - > pause ( ) ;
pause ( ) ;
}
}
else if ( change = = QGraphicsItem : : ItemSceneHasChanged )
else if ( change = = QGraphicsItem : : ItemSceneHasChanged )
{
{
if ( ! scene ( ) )
if ( ! scene ( ) )
mMediaObject - > stop ( ) ;
stop ( ) ;
else {
else {
QString absoluteMediaFilename ;
QString absoluteMediaFilename ;
@ -225,6 +226,16 @@ bool UBGraphicsMediaItem::isStopped() const
return mStopped ;
return mStopped ;
}
}
bool UBGraphicsMediaItem : : firstLoad ( ) const
{
return mFirstLoad ;
}
void UBGraphicsMediaItem : : setFirstLoad ( bool firstLoad )
{
mFirstLoad = firstLoad ;
}
qint64 UBGraphicsMediaItem : : mediaDuration ( ) const
qint64 UBGraphicsMediaItem : : mediaDuration ( ) const
{
{
return mMediaObject - > duration ( ) ;
return mMediaObject - > duration ( ) ;
@ -333,7 +344,7 @@ UBGraphicsScene* UBGraphicsMediaItem::scene()
void UBGraphicsMediaItem : : activeSceneChanged ( )
void UBGraphicsMediaItem : : activeSceneChanged ( )
{
{
if ( UBApplication : : boardController - > activeScene ( ) ! = scene ( ) )
if ( UBApplication : : boardController - > activeScene ( ) ! = scene ( ) )
mMediaObject - > pause ( ) ;
pause ( ) ;
}
}
@ -374,17 +385,19 @@ void UBGraphicsMediaItem::togglePlayPause()
}
}
if ( mMediaObject - > state ( ) = = QMediaPlayer : : StoppedState )
if ( mMediaObject - > state ( ) = = QMediaPlayer : : StoppedState )
mMediaObject - > play ( ) ;
{
play ( ) ;
}
else if ( mMediaObject - > state ( ) = = QMediaPlayer : : PlayingState ) {
else if ( mMediaObject - > state ( ) = = QMediaPlayer : : PlayingState ) {
if ( ( mMediaObject - > duration ( ) - mMediaObject - > position ( ) ) < = 0 ) {
if ( ( mMediaObject - > duration ( ) - mMediaObject - > position ( ) ) < = 0 ) {
mMediaObject - > stop ( ) ;
stop ( ) ;
mMediaObject - > play ( ) ;
play ( ) ;
}
}
else {
else {
mMediaObject - > pause ( ) ;
pause ( ) ;
if ( scene ( ) )
if ( scene ( ) )
scene ( ) - > setModified ( true ) ;
scene ( ) - > setModified ( true ) ;
}
}
@ -392,14 +405,14 @@ void UBGraphicsMediaItem::togglePlayPause()
else if ( mMediaObject - > state ( ) = = QMediaPlayer : : PausedState ) {
else if ( mMediaObject - > state ( ) = = QMediaPlayer : : PausedState ) {
if ( ( mMediaObject - > duration ( ) - mMediaObject - > position ( ) ) < = 0 )
if ( ( mMediaObject - > duration ( ) - mMediaObject - > position ( ) ) < = 0 )
mMediaObject - > stop ( ) ;
stop ( ) ;
mMediaObject - > play ( ) ;
play ( ) ;
}
}
else if ( mMediaObject - > mediaStatus ( ) = = QMediaPlayer : : LoadingMedia ) {
else if ( mMediaObject - > mediaStatus ( ) = = QMediaPlayer : : LoadingMedia ) {
mMediaObject - > setMedia ( mediaFileUrl ( ) ) ;
mMediaObject - > setMedia ( mediaFileUrl ( ) ) ;
mMediaObject - > play ( ) ;
play ( ) ;
}
}
}
}