Fixed displaying the remaining video playback time while playing a video. Added 
support to seek inside video playback by moving the timeline slider.

Signed-off-by: Jukka Selesniemi <[email protected]>
---
 src/videocontrolpanel.cpp |   88 ++----------------------------
 src/videocontrolpanel.h   |   26 ++-------
 src/videoplayer.cpp       |    4 +-
 src/videoplayer.h         |    6 +-
 src/videoseekbar.cpp      |  131 ++++++++++++++++++++++++++++-----------------
 src/videoseekbar.h        |   25 +++++----
 src/videoviewpage.cpp     |  123 +++++++++++++++++++++++++++++-------------
 src/videoviewpage.h       |    1 +
 8 files changed, 199 insertions(+), 205 deletions(-)

diff --git a/src/videocontrolpanel.cpp b/src/videocontrolpanel.cpp
index 760cecb..66ca2ff 100644
--- a/src/videocontrolpanel.cpp
+++ b/src/videocontrolpanel.cpp
@@ -42,45 +42,24 @@ VideoControlPanel::VideoControlPanel(QGraphicsItem *parent) 
: MStylableWidget(pa
     QGraphicsLinearLayout *controlPanelLayout3 = new 
QGraphicsLinearLayout(Qt::Horizontal);
     controlPanelLayout3->setSpacing(0);
     controlPanelLayout3->setContentsMargins(0, 0, 0, 0);
-    
-    //Duration label
-    //m_durationlabel = new MLabel(this);
-    //m_durationlabel->setObjectName("DurationLabel");
-    
+
     // Video Date label
     m_videodatelabel = new MLabel(this);
     m_videodatelabel->setObjectName("VideoDateLabel");
     
-    //Seekbar
-    m_duration = 0;
-    seekBarIsPressed = false;
-    m_videoSeekBar = new MSeekBar;
-    m_videoSeekBar->setObjectName("VideoSeekBar");
-    connect(m_videoSeekBar, SIGNAL(valueChanged(qint64)), 
SIGNAL(valueChanged(qint64)));
-    connect(m_videoSeekBar, SIGNAL(sliderPressed()), this, 
SLOT(sliderPressedHandle()));
-    connect(m_videoSeekBar, SIGNAL(sliderReleased()), this, 
SLOT(sliderReleasedHandle()));
-    //m_videoSeekBar->setMinLabelVisible(true);
-    //m_videoSeekBar->setMaxLabelVisible(true);
-    m_videoSeekBar->setHandleLabelVisible(true);
-    m_duration = 0;
-    seekBarIsPressed = false;
-    
     //Ticker
     m_ticker = new Ticker(this);
     m_ticker->setObjectName("TickerText");
         
     controlPanelLayout3->addItem(m_ticker);
     controlPanelLayout3->addItem(m_videodatelabel);
-    //controlPanelLayout3->addItem(m_durationlabel);
-    
+
     controlPanelLayout2->addItem(controlPanelLayout3);
-    //controlPanelLayout2->addItem(m_videoSeekBar);
-   
+
     controlPanelLayout->addItem(m_previousButton);
     controlPanelLayout->addItem(m_playButton);
     controlPanelLayout->addItem(m_nextButton);
-    controlPanelLayout->addItem(controlPanelLayout2);
-    //controlPanelLayout->addStretch();
+    controlPanelLayout->addItem(controlPanelLayout2);    
 }
 
 
@@ -89,9 +68,7 @@ VideoControlPanel::~VideoControlPanel()
     delete m_playButton;
     delete m_nextButton;
     delete m_previousButton;
-    delete m_videodatelabel;
-    //delete m_durationlabel;
-    delete m_videoSeekBar;
+    delete m_videodatelabel;    
     delete m_ticker;
 }
 
@@ -142,12 +119,6 @@ void 
VideoControlPanel::control_button_update(VideoPlayer::PlaybackState state)
     }
 }
 
-
-qint64 VideoControlPanel::value() {
-       return m_videoSeekBar->value();
-}
-
-
 void VideoControlPanel::setMediaName(const QString &MediaName) {
      m_ticker->setText2(MediaName);
 }
@@ -156,52 +127,3 @@ void VideoControlPanel::setMediaName(const QString 
&MediaName) {
 void VideoControlPanel::setMediaDate(const QString &MediaDate) {
     m_videodatelabel->setText(MediaDate);
 }
-
-
-void VideoControlPanel::setDuration(qint64 duration) {
-       m_duration = duration;
-       m_videoSeekBar->setMinimum(0);
-    m_videoSeekBar->setMaximum(duration);
-    m_videoSeekBar->setMinLabel("0:00");
-    int minutes = (duration / 1000) / 60;
-    int seconds = (duration / 1000) % 60;
-    //m_videoSeekBar->setMaxLabel(QString("%1:%2").arg(minutes).arg(seconds, 
2, 10, QChar('0')));
-    //m_durationlabel->setText(QString("%1:%2").arg(minutes).arg(seconds, 2, 
10, QChar('0')));
-}
-
-
-void VideoControlPanel::setValue(qint64 value) {
-       if (seekBarIsPressed == false)
-               m_videoSeekBar->setValue(value);
-       
-       if (value % 1000)
-               value += 1000;
-       if (value > m_duration)
-        value = m_duration;
-       int minutes = (value / 1000) / 60;
-    int seconds = (value / 1000) % 60;
-       
//m_videoSeekBar->setMinLabel(QString("%1:%2").arg(minutes).arg(seconds, 2, 10, 
QChar('0')));
-        //m_durationlabel->setText(QString("%1:%2").arg(minutes).arg(seconds, 
2, 10, QChar('0')));
-}
-
-
-void VideoControlPanel::sliderPressedHandle() {
-    seekBarIsPressed = true;
-    emit sliderPressed();
-}
- 
-void VideoControlPanel::sliderReleasedHandle() {
-    seekBarIsPressed = false;
-    emit sliderReleased();
-}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/videocontrolpanel.h b/src/videocontrolpanel.h
index 49a6016..57f1e00 100644
--- a/src/videocontrolpanel.h
+++ b/src/videocontrolpanel.h
@@ -33,28 +33,17 @@ class VideoControlPanel : public MStylableWidget
 
 public:
     VideoControlPanel(QGraphicsItem *parent = 0);
-    ~VideoControlPanel();
-    qint64 value();
+    ~VideoControlPanel();    
     void setMediaName(const QString &MediaName);
-    void setMediaDate(const QString &MediaDate);
-    void setDuration(qint64 duration);
-       void setValue(qint64 value);
+    void setMediaDate(const QString &MediaDate);    
     
 public slots:
     void control_button_clicked();
-    void control_button_update(VideoPlayer::PlaybackState state);
-    void sliderPressedHandle();
-    void sliderReleasedHandle();
+    void control_button_update(VideoPlayer::PlaybackState state);    
 
 signals:
     // Playback btns
     void btn_clicked(const QString &button);
-    
-    // Seekbar
-    void valueChanged(qint64);
-    void sliderPressed();
-    void sliderReleased();
-    void outOfLoadedContentRange();
     void mousePress();
     
 private:
@@ -62,14 +51,9 @@ private:
     MButton *m_playButton;
     MButton *m_nextButton;
     MButton *m_nextButton2;
-    MButton *m_previousButton;
-    bool seekBarIsPressed;
-    MSeekBar *m_videoSeekBar;
-    qint64 m_duration;
-    MLabel *m_durationlabel;
-    MLabel *m_playingtimelabel;
+    MButton *m_previousButton;    
     MLabel *m_videodatelabel;
-    Ticker *m_ticker;    
+    Ticker *m_ticker;
 
 protected:
        virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/videoplayer.cpp b/src/videoplayer.cpp
index 1013602..cb60613 100644
--- a/src/videoplayer.cpp
+++ b/src/videoplayer.cpp
@@ -163,9 +163,9 @@ void 
VideoPlayer::handlePlayerStateChanged(QMediaPlayer::State state)
 }
 
 
-void VideoPlayer::seek(int seconds)
+void VideoPlayer::seek(qint64 position)
 {
-    m_mediaPlayer->setPosition(seconds * 1000);
+    m_mediaPlayer->setPosition(position);
 }
 
 void VideoPlayer::closePlayer()
diff --git a/src/videoplayer.h b/src/videoplayer.h
index fecc34d..e3f27fd 100644
--- a/src/videoplayer.h
+++ b/src/videoplayer.h
@@ -78,9 +78,9 @@ public slots:
 
     /// @brief Stop playback of the video
     void stop();
-    
-    void seek(int seconds);
-    
+
+    /// @brief Seek in video playback
+    void seek(qint64 position);
     
     /// @brief Move video playback forward to next chapter or a fixed time 
period if no chapters exist
     void windForward();
diff --git a/src/videoseekbar.cpp b/src/videoseekbar.cpp
index 7649582..3fc4824 100644
--- a/src/videoseekbar.cpp
+++ b/src/videoseekbar.cpp
@@ -19,8 +19,10 @@
 #include <MSeekBar>
 #include <MLayout>
 #include <MLocale>
+#include <QtDebug>
 
-VideoSeekbar::VideoSeekbar(QGraphicsItem *parent) : MStylableWidget(parent)
+VideoSeekbar::VideoSeekbar(QGraphicsItem *parent) : MStylableWidget(parent),
+m_duration(0)
 {
     qDebug() << "VideoSeekbar::VideoSeekbar";
     setObjectName("VideoSeekbarWidget");
@@ -32,28 +34,21 @@ VideoSeekbar::VideoSeekbar(QGraphicsItem *parent) : 
MStylableWidget(parent)
     
     m_videoSeekBar = new MSeekBar;
     m_videoSeekBar->setObjectName("VideoSeekBar");
-    connect(m_videoSeekBar, SIGNAL(valueChanged(qint64)), 
SIGNAL(valueChanged(qint64)));
+    connect(m_videoSeekBar, SIGNAL(valueChanged(int)), this, 
SLOT(valueChangedHandle(int)));
     connect(m_videoSeekBar, SIGNAL(sliderPressed()), this, 
SLOT(sliderPressedHandle()));
     connect(m_videoSeekBar, SIGNAL(sliderReleased()), this, 
SLOT(sliderReleasedHandle()));
-    //connect(m_videoSeekBar, SIGNAL(outOfLoadedContentRange()), 
SIGNAL(outOfLoadedContentRange()));
-    
+    connect(m_videoSeekBar, SIGNAL(outOfLoadedContentRange()), this, 
SLOT(outOfLoadedContentRangeHandle()));
+
     m_videoSeekBar->setMinLabelVisible(true);
     m_videoSeekBar->setMaxLabelVisible(true);
-    m_videoSeekBar->setHandleLabelVisible(true); //?????????
+    m_videoSeekBar->setHandleLabelVisible(true);
     videoseekbaLayout->addItem(m_videoSeekBar);
     
     videoseekbaLayout->setAlignment(m_videoSeekBar, Qt::AlignHCenter);
     
-    this->setAcceptHoverEvents(true);
-    //qDebug() << "meegovideo acceptHoverEvents: " << 
this->acceptHoverEvents();
-    //MWidgetController::setAcceptHoverEvents(true);
-    //qDebug() << "meegovideo acceptHoverEvents: " << 
this->acceptHoverEvents();
-    
-    m_duration = 0;
-    seekBarIsPressed = false;
+    this->setAcceptHoverEvents(true);    
 }
 
-
 qint64 VideoSeekbar::value() {
        return m_videoSeekBar->value();
 }
@@ -63,66 +58,104 @@ void 
VideoSeekbar::mousePressEvent(QGraphicsSceneMouseEvent *event) {
     MWidgetController::mousePressEvent(event);
 }
 
-
 void VideoSeekbar::hoverLeaveEvent(QGraphicsSceneMouseEvent *event) {
     emit hoverleave();
     //MWidgetController::hoverLeaveEvent(event);
 }
 
+void VideoSeekbar::updateLabels()
+{
+    qint64 time = m_videoSeekBar->value();
+
+    int nMinLabelHours   = (time / 1000) / 3600;
+    int nMinLabelMinutes = ((time / 1000) % 3600) / 60;
+    int nMinLabelSeconds = ((time / 1000) % 3600) % 60;
+
+    if (nMinLabelHours == 0) {
+        
m_videoSeekBar->setMinLabel(QString("%1:%2").arg(nMinLabelMinutes).arg(nMinLabelSeconds,
 2, 10, QChar('0')));
+    }
+    else {
+        
m_videoSeekBar->setMinLabel(QString("%1:%2:%3").arg(nMinLabelHours).arg(nMinLabelMinutes,
 2, 10, QChar('0')).arg(nMinLabelSeconds, 2, 10, QChar('0')));
+    }
+
+    qint64 timeLeft = m_duration - time;
+
+    int nMaxLabelHours   = (timeLeft / 1000) / 3600;
+    int nMaxLabelMinutes = ((timeLeft / 1000) % 3600) / 60;
+    int nMaxLabelSeconds = ((timeLeft / 1000) % 3600) % 60;
+
+    if (nMaxLabelHours == 0) {
+        
m_videoSeekBar->setMaxLabel(QString("%1:%2").arg(nMaxLabelMinutes).arg(nMaxLabelSeconds,
 2, 10, QChar('0')));
+    }
+    else {
+        
m_videoSeekBar->setMaxLabel(QString("%1:%2:%3").arg(nMaxLabelHours).arg(nMaxLabelMinutes,
 2, 10, QChar('0')).arg(nMaxLabelSeconds, 2, 10, QChar('0')));
+    }
+}
 
 void VideoSeekbar::setDuration(qint64 duration) {
+
+    qCritical("VideoSeekbar::setDuration -->");
+
+    qCritical() << "duration: " << duration;
+
     m_duration = duration;
-    m_videoSeekBar->setMinimum(0);
-    m_videoSeekBar->setMaximum(duration);
-    m_videoSeekBar->setMinLabel("0:00");
-    int hours   = (duration / 1000) / 3600;
-    int minutes = ((duration / 1000) % 3600) / 60;
-    int seconds = ((duration / 1000) % 3600) % 60;
-    if (hours == 0)
-        m_videoSeekBar->setMaxLabel(QString("%1:%2").arg(minutes).arg(seconds, 
2, 10, QChar('0')));
-    else
-        
m_videoSeekBar->setMaxLabel(QString("%1:%2:%3").arg(hours).arg(minutes, 2, 10, 
QChar('0')).arg(seconds, 2, 10, QChar('0')));
+
+    m_videoSeekBar->setRange(0, m_duration);
+    m_videoSeekBar->setLoadedContentRange(0, m_duration);
+
+    qCritical("VideoSeekbar::setDuration <--");
 }
 
 void VideoSeekbar::setValue(qint64 value) {
-    if (seekBarIsPressed == false)
-        m_videoSeekBar->setValue(value);
-    if (value % 1000)
-        value += 1000;
-    if (value > m_duration)
-        value = m_duration;
-    int hours   = (value / 1000) / 3600;     
-    int minutes = ((value / 1000) % 3600) / 60;
-    int seconds = ((value / 1000) % 3600) % 60;
-    if (hours == 0)
-        m_videoSeekBar->setMinLabel(QString("%1:%2").arg(minutes).arg(seconds, 
2, 10, QChar('0')));
-    else
-        
m_videoSeekBar->setMinLabel(QString("%1:%2:%3").arg(hours).arg(minutes, 2, 10, 
QChar('0')).arg(seconds, 2, 10, QChar('0')));
-}
 
+    m_videoSeekBar->setValue(value);
 
+    updateLabels();
+}
 
 void VideoSeekbar::sliderPressedHandle() {
-    seekBarIsPressed = true;
     emit sliderPressed();
 }
  
 void VideoSeekbar::sliderReleasedHandle() {
-    seekBarIsPressed = false;
     emit sliderReleased();
 }
 
+void VideoSeekbar::valueChangedHandle(int newValue) {
+    qCritical("VideoSeekbar::valueChangedHandle -->");
+
+    qCritical() << "changed value: " << newValue;
+
+    qint64 time = m_videoSeekBar->value();
+
+    qCritical() << "seekbar value: " << time;
 
+    int nHours   = (time / 1000) / 3600;
+    int nMinutes = ((time / 1000) % 3600) / 60;
+    int nSeconds = ((time / 1000) % 3600) % 60;
+
+    if (nHours == 0) {
+        
m_videoSeekBar->setHandleLabel(QString("%1:%2").arg(nMinutes).arg(nSeconds, 2, 
10, QChar('0')));
+    }
+    else {
+        
m_videoSeekBar->setHandleLabel(QString("%1:%2:%3").arg(nHours).arg(nMinutes, 2, 
10, QChar('0')).arg(nSeconds, 2, 10, QChar('0')));
+    }
+
+    qCritical("VideoSeekbar::valueChangedHandle <--");
+}
+
+void VideoSeekbar::outOfLoadedContentRangeHandle()
+{
+    qCritical("VideoSeekbar::outOfLoadedContentRangeHandle -->");
+
+    qCritical("VideoSeekbar::outOfLoadedContentRangeHandle <--");
+
+    qFatal("out of range");
+}
 
 VideoSeekbar::~VideoSeekbar()
 {
-    delete m_videoSeekBar;
+    if (0 != m_videoSeekBar) {
+        delete m_videoSeekBar;
+    }
 }
- 
- 
- 
- 
- 
- 
- 
- 
diff --git a/src/videoseekbar.h b/src/videoseekbar.h
index 0dbc674..d6be0ff 100644
--- a/src/videoseekbar.h
+++ b/src/videoseekbar.h
@@ -10,8 +10,8 @@
  *
 ****************************************************************************/
 
-#ifndef VIDEOSEEKBAT_H
-#define VIDEOSEEKBAT_H
+#ifndef VIDEOSEEKBAR_H
+#define VIDEOSEEKBAR_H
 
 #include <MStylableWidget>
 #include <MWidgetStyle>
@@ -24,21 +24,26 @@ class VideoSeekbar : public MStylableWidget
 public:
     VideoSeekbar(QGraphicsItem *parent = 0);
     ~VideoSeekbar();
-       qint64 value();
-       void setDuration(qint64 duration);
-       void setValue(qint64 value);
+    qint64 value();
+    void setDuration(qint64 duration);
+    void setValue(qint64 value);
+
+private:
+    void updateLabels();
 
 private slots:
     void sliderPressedHandle();
     void sliderReleasedHandle();
+    void valueChangedHandle(int newValue);
+    void outOfLoadedContentRangeHandle();
 
 signals:
-    void valueChanged(qint64);
+    void valueChanged(int);
     void sliderPressed();
     void sliderReleased();
     void outOfLoadedContentRange();
     void mousePress();
-    void hoverleave();
+    void hoverleave();    
     
 private:
     M_STYLABLE_WIDGET(MWidgetStyle);
@@ -47,8 +52,8 @@ private:
     qint64 m_duration;
 
 protected:
-       virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
-       virtual void hoverLeaveEvent(QGraphicsSceneMouseEvent *event);
+    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
+    virtual void hoverLeaveEvent(QGraphicsSceneMouseEvent *event);
 };
 
-#endif // VIDEOSEEKBAT_H
+#endif // VIDEOSEEKBAR_H
diff --git a/src/videoviewpage.cpp b/src/videoviewpage.cpp
index c682e2c..76b7822 100644
--- a/src/videoviewpage.cpp
+++ b/src/videoviewpage.cpp
@@ -14,12 +14,14 @@
 #include "controlpanel.h"
 #include "videoplayer.h"
 #include "thumbnailmanager.h"
+#include <QtDebug>
 
 VideoViewPage::VideoViewPage(QGraphicsItem *parent)
     : MApplicationPage(parent),
     m_startFrame(0),
-    m_playerPreSate(VideoPlayer::StoppedState)
-{
+    m_playerPreSate(VideoPlayer::StoppedState),
+    m_sliderPressed(false)
+{    
 }
 
 void VideoViewPage::createContent()
@@ -28,6 +30,7 @@ void VideoViewPage::createContent()
 
     setAutoMarginsForComponentsEnabled(false);
     //setComponentsDisplayMode(MApplicationPage::AllComponents, 
MApplicationPageModel::AutoHide);
+
     QGraphicsWidget *panel = centralWidget();
 
     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
@@ -37,7 +40,8 @@ void VideoViewPage::createContent()
     connect(m_timer, SIGNAL(timeout()), this, SLOT(hideSeekBar())); //fixme
     
     connect(this, SIGNAL(backButtonClicked ()), this, 
SLOT(backToPreviousPageHandle()));
-        
+    
+    
     m_videoPlayer = new VideoPlayer(panel);
     connect(m_videoPlayer, 
SIGNAL(playerStateChanged(VideoPlayer::PlaybackState)), 
SLOT(playerStateChanged(VideoPlayer::PlaybackState)));
     connect(m_videoPlayer, SIGNAL(positionChanged(qint64)), 
SLOT(positionChanged(qint64)));
@@ -52,20 +56,15 @@ void VideoViewPage::createContent()
     m_videoControlPanelOverlay->setObjectName("VideoControlPanelOverLay");
     m_videoControlPanelOverlay->setContentsMargins(0, 0, 0, 0);
        
-       MWidget *VideoControlPanelWidget = m_videoControlPanelOverlay->widget();
-       QGraphicsLinearLayout *VideoControlPanelLayout = new 
QGraphicsLinearLayout(Qt::Horizontal, VideoControlPanelWidget);
+    MWidget *VideoControlPanelWidget = m_videoControlPanelOverlay->widget();
+    QGraphicsLinearLayout *VideoControlPanelLayout = new 
QGraphicsLinearLayout(Qt::Horizontal, VideoControlPanelWidget);
     VideoControlPanelLayout->setSpacing(0);
     VideoControlPanelLayout->setContentsMargins(0, 0, 0, 0);
      
     m_videoControlPanel = new VideoControlPanel(NULL);
     connect(m_videoControlPanel, SIGNAL(btn_clicked(const QString &)), this, 
SLOT(control_btn_press_handler(const QString &)));
     connect(this, SIGNAL(StateChanged(VideoPlayer::PlaybackState)), 
m_videoControlPanel, SLOT(control_button_update(VideoPlayer::PlaybackState)));
-    
-    connect(m_videoControlPanel, SIGNAL(valueChanged(qint64)), this, 
SLOT(seekingHandle(qint64)));
-    connect(m_videoControlPanel, SIGNAL(sliderPressed()), this, 
SLOT(sliderPressed()));
-    connect(m_videoControlPanel, SIGNAL(sliderReleased()), this, 
SLOT(sliderReleased()));
-    connect(m_videoControlPanel, SIGNAL(mousePress()), this, 
SLOT(mousePressHandle()));
-    
+        
     VideoControlPanelLayout->addItem(m_videoControlPanel);
     m_videoControlPanelOverlay->appear();
     
@@ -92,7 +91,8 @@ void VideoViewPage::createContent()
      if (!m_activewindow)
         return;
     else
-       m_activewindow->showFullScreen();
+        m_activewindow->showFullScreen();
+
     m_videoSeekbarOverlay->disappear();
     m_videoControlPanelOverlay->disappear();
 }
@@ -125,20 +125,32 @@ void 
VideoViewPage::playerStateChanged(VideoPlayer::PlaybackState state)
     default:
         break;
     }
+    
+    
+    
+    
 }
 
 void VideoViewPage::positionChanged(qint64 progress)
 {
-    if (m_videoControlPanel)
-        m_videoControlPanel->setValue(progress);
+    qCritical("VideoViewPage::positionChanged -->");
+
+    qCritical() << "progress: " << progress;
+
     if (m_videoseekbar)
+    {
         m_videoseekbar->setValue(progress);
+    }
+
+    qCritical("VideoViewPage::positionChanged <--");
 }
 
 void VideoViewPage::durationChanged(qint64 duration)
 {
-    if (m_videoControlPanel)
-        m_videoControlPanel->setDuration(duration);
+    qCritical("VideoViewPage::durationChanged -->");
+
+    qCritical() << "duration: " << duration;
+
     if (m_videoControlPanel) {
         m_videoControlPanel->setMediaName(ThumbnailManager::instance()->title( 
m_videoPlayer->mediaUrl().path()));
         m_videoControlPanel->setMediaDate(ThumbnailManager::instance()->date( 
m_videoPlayer->mediaUrl().path()).toString("MMM d yyyy"));
@@ -146,10 +158,15 @@ void VideoViewPage::durationChanged(qint64 duration)
     
     if (m_videoseekbar)
         m_videoseekbar->setDuration(duration);
+
+    qCritical("VideoViewPage::durationChanged <--");
 }
 
 void VideoViewPage::mediaChanged( const QMediaContent & media ) {
-   
+
+    qCritical("VideoViewPage::mediaChanged -->");
+
+    qCritical("VideoViewPage::mediaChanged <--");
 }
 
 
@@ -181,23 +198,48 @@ void VideoViewPage::control_btn_press_handler(const 
QString &press_btn)
 
 
 void VideoViewPage::seekingHandle(qint64 position) {
-    qDebug() << "VideoViewPage: seekingHandle" << position;  
+
+    qCritical("VideoViewPage::seekingHandle -->");
+
+    qCritical() << "position: " << position;
+
+    qDebug() << "VideoViewPage: seekingHandle" << position;
+
+    m_videoPlayer->seek(position);
+
+    qCritical("VideoViewPage::seekingHandle <--");
 }
 
 
-void VideoViewPage::sliderPressed() {
-    qDebug() << "meegovideo: sliderPressed  " << m_videoControlPanel->value();
+void VideoViewPage::sliderPressed() {    
+
+    qCritical("VideoViewPage::sliderPressed -->");
+
+    m_sliderPressed = true;
+
+    m_videoPlayer->pause();
+
+    qDebug() << "meegovideo: sliderPressed  " << m_videoseekbar->value();
+
+    qCritical("VideoViewPage::sliderPressed <--");
 }
 
 
 void VideoViewPage::sliderReleased() {
-    qDebug() << "meegovideo: sliderReleased" << m_videoseekbar->value();
-    int position;
-    //position = m_videoControlPanel->value() / 1000;
-    position = m_videoseekbar->value() / 1000;
-    if (m_videoseekbar->value() % 1000)
-        position++;
-    m_videoPlayer->seek(position);
+
+    qCritical("VideoViewPage::sliderReleased -->");
+
+    m_sliderPressed = false;
+
+    qint64 nVideoSeekBarValue = m_videoseekbar->value();
+
+    qCritical() << "VideoViewPage::sliderReleased: " << nVideoSeekBarValue;
+
+    m_videoPlayer->seek(nVideoSeekBarValue);
+
+    m_videoPlayer->play(nVideoSeekBarValue);
+
+    qCritical("VideoViewPage::sliderReleased <--");
 }
 
 
@@ -207,11 +249,11 @@ void VideoViewPage::backToPreviousPageHandle() {
     m_videoSeekbarOverlay->disappear();
     m_videoControlPanelOverlay->disappear();
     m_videoPlayer->closePlayer();
-    
+
     if (!m_activewindow)
         return;
     else
-       m_activewindow->showNormal();
+        m_activewindow->showNormal();
 }
 
 
@@ -222,17 +264,24 @@ void VideoViewPage::mousePressHandle() {
     if (!m_activewindow)
         return;
     else
-       m_activewindow->showNormal();
-    //m_timer->stop();
+        m_activewindow->showNormal();
     m_timer->start(4000);  
 }
 
 void VideoViewPage::hideSeekBar() {
-    m_videoSeekbarOverlay->disappear();
-    m_videoControlPanelOverlay->disappear();
-    if (!m_activewindow)
-        return;
+    // Do not hide seekbar when slider is pressed.
+    if (true == m_sliderPressed)
+    {
+        // Restart timer.
+        m_timer->start(4000);
+    }
     else
-       m_activewindow->showFullScreen();
+    {
+        m_videoSeekbarOverlay->disappear();
+        m_videoControlPanelOverlay->disappear();
+        if (!m_activewindow)
+            return;
+        else
+            m_activewindow->showFullScreen();
+    }
 }
-
diff --git a/src/videoviewpage.h b/src/videoviewpage.h
index 8b1ad6b..32706d8 100644
--- a/src/videoviewpage.h
+++ b/src/videoviewpage.h
@@ -75,6 +75,7 @@ private:
     qint64 m_startFrame;
     QTimer *m_timer;
     MWindow *m_activewindow;
+    bool m_sliderPressed;
     
 protected:
        virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
-- 
1.7.0.4

_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev

Reply via email to