42 |
41 |
43 // ------------------------------------------------------------------------------------------------- |
42 // ------------------------------------------------------------------------------------------------- |
44 // QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar() |
43 // QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar() |
45 // ------------------------------------------------------------------------------------------------- |
44 // ------------------------------------------------------------------------------------------------- |
46 // |
45 // |
47 QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar( |
46 QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar( |
48 QMPXVideoPlaybackControlsController* controller ) |
47 QMPXVideoPlaybackControlsController* controller ) |
49 : mController( controller ) |
48 : mController( controller ) |
50 , mSeekStartTimer( NULL ) |
49 , mSeekStartTimer( NULL ) |
51 , mRetrieveButtonTimer( NULL ) |
50 , mRetrieveButtonTimer( NULL ) |
52 , mSeekingState( EMPXNotSeeking ) |
51 , mSeekingState( EMPXNotSeeking ) |
53 , mInitialized( false ) |
52 , mInitialized( false ) |
54 , mNeverVisibled( true ) |
|
55 , mPosition( 0 ) |
53 , mPosition( 0 ) |
56 , mDuration( 0 ) |
54 , mDuration( 0 ) |
57 , mAspectRatio( EMPXPbvCmdNaturalAspectRatio ) |
55 , mAspectRatio( EMPXPbvCmdNaturalAspectRatio ) |
58 { |
56 { |
59 MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar")); |
57 MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar")); |
60 |
58 |
61 mToolBar = mController->view()->toolBar(); |
59 mToolBar = mController->view()->toolBar(); |
62 mToolBar->setOrientation( Qt::Horizontal ); |
60 mToolBar->setOrientation( Qt::Horizontal ); |
63 HbEffect::disable( mToolBar ); |
61 |
64 |
|
65 mController->view()->hideItems( Hb::ToolBarItem ); |
62 mController->view()->hideItems( Hb::ToolBarItem ); |
66 |
63 |
67 initialize(); |
64 initialize(); |
68 } |
65 } |
69 |
66 |
183 } |
179 } |
184 |
180 |
185 mDuration = (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier; |
181 mDuration = (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier; |
186 |
182 |
187 // |
183 // |
188 // Create a timer for seeking. |
184 // Create a timer for seeking. |
189 // We will issue SetPosition every KSeekingTimeOut msec to show the current frame to user |
185 // We will issue SetPosition every KSeekingTimeOut msec to show the current frame to user |
190 // |
186 // |
191 mSeekStartTimer = new QTimer(); |
187 mSeekStartTimer = new QTimer(); |
192 mSeekStartTimer->setSingleShot( true ); |
188 mSeekStartTimer->setSingleShot( true ); |
193 mSeekStartTimer->setInterval( KSeekStartTimeOut ); |
189 mSeekStartTimer->setInterval( KSeekStartTimeOut ); |
194 |
190 |
195 // |
191 // |
196 // get window size |
192 // get window size |
197 // |
193 // |
198 RWindow *window = mController->view()->getWindow(); |
194 RWindow *window = mController->view()->getWindow(); |
199 TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) ); |
195 TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) ); |
200 |
196 |
201 // |
197 // |
202 // get window aspect ratio |
198 // get window aspect ratio |
203 // if device is in portrait mode, width > height |
199 // if device is in portrait mode, width > height |
204 // if device is in landscape mode, width < height |
200 // if device is in landscape mode, width < height |
205 // |
201 // |
206 TReal32 width = (TReal32) displayRect.Width(); |
202 TReal32 width = (TReal32) displayRect.Width(); |
207 TReal32 height = (TReal32) displayRect.Height(); |
203 TReal32 height = (TReal32) displayRect.Height(); |
208 mDisplayAspectRatio = (width > height)? (width / height) : (height / width); |
204 mDisplayAspectRatio = (width > height)? (width / height) : (height / width); |
209 |
|
210 } |
205 } |
211 } |
206 } |
212 |
207 |
213 // ------------------------------------------------------------------------------------------------- |
208 // ------------------------------------------------------------------------------------------------- |
214 // QMPXVideoPlaybackToolBar::playPause() |
209 // QMPXVideoPlaybackToolBar::playPause() |
525 mButtonActions[EMPX1stButton]->setEnabled( false ); |
526 mButtonActions[EMPX1stButton]->setEnabled( false ); |
526 } |
527 } |
527 else |
528 else |
528 { |
529 { |
529 // |
530 // |
530 // check if video clip has same aspect ratio as display window |
531 // check if video clip has same aspect ratio as display window |
531 // |
532 // |
532 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight; |
533 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight; |
533 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true; |
534 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true; |
534 |
535 |
535 // |
536 // |
536 // enable or dim 'aspect ratio' buttons accordingly |
537 // enable or dim 'aspect ratio' buttons accordingly |
537 // |
538 // |
538 mButtonActions[EMPX1stButton]->setEnabled( enabled ); |
539 mButtonActions[EMPX1stButton]->setEnabled( enabled ); |
539 |
540 |
540 if ( mButtons.count() ) |
541 if ( mButtons.count() ) |
541 { |
542 { |
542 disconnect( mButtons[EMPX1stButton], SIGNAL( released() ) ); |
543 disconnect( mButtons[EMPX1stButton], SIGNAL( released() ), 0, 0 ); |
543 connect( mButtons[EMPX1stButton], SIGNAL( released() ), |
544 connect( mButtons[EMPX1stButton], SIGNAL( released() ), |
544 this, SLOT( changeAspectRatio() ) ); |
545 this, SLOT( changeAspectRatio() ) ); |
545 } |
546 } |
546 } |
547 } |
547 } |
548 } |
548 else if ( mController->viewMode() == EAudioOnlyView ) |
549 else if ( mController->viewMode() == EAudioOnlyView ) |
549 { |
550 { |
550 // |
551 // |
551 // Show share button |
552 // Show share button |
552 // |
553 // |
588 else |
589 else |
589 { |
590 { |
590 mButtonActions[EMPX5thButton]->setEnabled( true ); |
591 mButtonActions[EMPX5thButton]->setEnabled( true ); |
591 } |
592 } |
592 |
593 |
593 if ( ! details->mSeekable ) |
594 if ( details->mSeekable && details->mPausableStream ) |
|
595 { |
|
596 mButtonActions[EMPX2ndButton]->setEnabled( true ); |
|
597 mButtonActions[EMPX4thButton]->setEnabled( true ); |
|
598 } |
|
599 else |
594 { |
600 { |
595 mButtonActions[EMPX2ndButton]->setEnabled( false ); |
601 mButtonActions[EMPX2ndButton]->setEnabled( false ); |
596 mButtonActions[EMPX4thButton]->setEnabled( false ); |
602 mButtonActions[EMPX4thButton]->setEnabled( false ); |
597 } |
603 } |
|
604 |
|
605 if ( details->mPausableStream ) |
|
606 { |
|
607 mButtonActions[EMPX3rdButton]->setEnabled( true ); |
|
608 } |
598 else |
609 else |
599 { |
610 { |
600 mButtonActions[EMPX2ndButton]->setEnabled( true ); |
|
601 mButtonActions[EMPX4thButton]->setEnabled( true ); |
|
602 } |
|
603 |
|
604 if ( ! details->mPausableStream ) |
|
605 { |
|
606 mButtonActions[EMPX3rdButton]->setEnabled( false ); |
611 mButtonActions[EMPX3rdButton]->setEnabled( false ); |
607 } |
612 } |
|
613 |
|
614 // |
|
615 // toolbar creates button once it gets visible, so we don't know exact timing when toolbar |
|
616 // creates button, so start timer to get layout information once the toolbar gets visible. |
|
617 // This is needed since we don't use toolbar in proper way. |
|
618 // |
|
619 if ( ! mRetrieveButtonTimer && ! mButtons.count() ) |
|
620 { |
|
621 mRetrieveButtonTimer = new QTimer(); |
|
622 mRetrieveButtonTimer->setSingleShot( false ); |
|
623 mRetrieveButtonTimer->setInterval( KRetrieveButtonTimeOut ); |
|
624 connect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) ); |
|
625 |
|
626 mRetrieveButtonTimer->start(); |
|
627 } |
|
628 |
|
629 durationChanged( (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier ); |
|
630 } |
|
631 |
|
632 // ------------------------------------------------------------------------------------------------- |
|
633 // QMPXVideoPlaybackToolBar::openDetailsView() |
|
634 // ------------------------------------------------------------------------------------------------- |
|
635 // |
|
636 void QMPXVideoPlaybackToolBar::openDetailsView() |
|
637 { |
|
638 MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::openDetailsView()")); |
|
639 |
|
640 TPlaybackViewMode viewMode = mController->viewMode(); |
|
641 |
|
642 if ( viewMode == EFullScreenView ) |
|
643 { |
|
644 mController->changeViewMode( EDetailsView ); |
|
645 } |
|
646 } |
|
647 |
|
648 // ------------------------------------------------------------------------------------------------- |
|
649 // QMPXVideoPlaybackToolBar::positionChanged |
|
650 // ------------------------------------------------------------------------------------------------- |
|
651 // |
|
652 void QMPXVideoPlaybackToolBar::positionChanged( int position ) |
|
653 { |
|
654 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::positionChanged position = %d"), position ); |
|
655 |
|
656 mPosition = position; |
|
657 } |
|
658 |
|
659 // ------------------------------------------------------------------------------------------------- |
|
660 // QMPXVideoPlaybackToolBar::durationChanged |
|
661 // ------------------------------------------------------------------------------------------------- |
|
662 // |
|
663 void QMPXVideoPlaybackToolBar::durationChanged( int duration ) |
|
664 { |
|
665 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::durationChanged duration = %d"), duration ); |
|
666 |
|
667 mDuration = duration; |
|
668 } |
|
669 |
|
670 // ------------------------------------------------------------------------------------------------- |
|
671 // QMPXVideoPlaybackToolBar::setVisible |
|
672 // ------------------------------------------------------------------------------------------------- |
|
673 // |
|
674 void QMPXVideoPlaybackToolBar::setVisible( bool visible ) |
|
675 { |
|
676 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::setVisible visible = %d"), visible ); |
|
677 |
|
678 if ( visible ) |
|
679 { |
|
680 mController->view()->showItems( Hb::ToolBarItem ); |
|
681 } |
608 else |
682 else |
609 { |
683 { |
610 mButtonActions[EMPX3rdButton]->setEnabled( true ); |
|
611 } |
|
612 } |
|
613 |
|
614 // ------------------------------------------------------------------------------------------------- |
|
615 // QMPXVideoPlaybackToolBar::openDetailsView() |
|
616 // ------------------------------------------------------------------------------------------------- |
|
617 // |
|
618 void QMPXVideoPlaybackToolBar::openDetailsView() |
|
619 { |
|
620 MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::openDetailsView()")); |
|
621 |
|
622 TPlaybackViewMode viewMode = mController->viewMode(); |
|
623 |
|
624 if ( viewMode == EFullScreenView ) |
|
625 { |
|
626 mController->changeViewMode( EDetailsView ); |
|
627 } |
|
628 } |
|
629 |
|
630 // ------------------------------------------------------------------------------------------------- |
|
631 // QMPXVideoPlaybackToolBar::positionChanged |
|
632 // ------------------------------------------------------------------------------------------------- |
|
633 // |
|
634 void QMPXVideoPlaybackToolBar::positionChanged( int position ) |
|
635 { |
|
636 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::positionChanged position = %d"), position ); |
|
637 |
|
638 mPosition = position; |
|
639 retrieveButtons(); |
|
640 } |
|
641 |
|
642 // ------------------------------------------------------------------------------------------------- |
|
643 // QMPXVideoPlaybackToolBar::durationChanged |
|
644 // ------------------------------------------------------------------------------------------------- |
|
645 // |
|
646 void QMPXVideoPlaybackToolBar::durationChanged( int duration ) |
|
647 { |
|
648 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::durationChanged duration = %d"), duration ); |
|
649 |
|
650 mDuration = duration; |
|
651 } |
|
652 |
|
653 // ------------------------------------------------------------------------------------------------- |
|
654 // QMPXVideoPlaybackToolBar::setVisible |
|
655 // ------------------------------------------------------------------------------------------------- |
|
656 // |
|
657 void QMPXVideoPlaybackToolBar::setVisible( bool visible ) |
|
658 { |
|
659 MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::setVisible visible = %d"), visible ); |
|
660 |
|
661 if ( visible ) |
|
662 { |
|
663 mController->view()->showItems( Hb::ToolBarItem ); |
|
664 |
|
665 if ( mNeverVisibled ) |
|
666 { |
|
667 mNeverVisibled = false; |
|
668 |
|
669 |
|
670 // |
|
671 // toolbar creates button once it gets visible, so we don't know exact timing when toolbar |
|
672 // creates button, so start timer to get layout information once the toolbar gets visible. |
|
673 // This is needed since we don't use toolbar in proper way. |
|
674 // |
|
675 mRetrieveButtonTimer = new QTimer(); |
|
676 mRetrieveButtonTimer->setSingleShot( false ); |
|
677 mRetrieveButtonTimer->setInterval( KRetrieveButtonTimeOut ); |
|
678 connect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) ); |
|
679 |
|
680 mRetrieveButtonTimer->start(); |
|
681 } |
|
682 } |
|
683 else |
|
684 { |
|
685 mController->view()->hideItems( Hb::ToolBarItem ); |
684 mController->view()->hideItems( Hb::ToolBarItem ); |
686 } |
685 } |
687 } |
686 } |
688 |
687 |
689 // ------------------------------------------------------------------------------------------------- |
688 // ------------------------------------------------------------------------------------------------- |