Commit 41937ff2 authored by Ludovic Fauvet's avatar Ludovic Fauvet

The slider under the clip preview is seeking while the video plays

parent 42af462b
......@@ -29,6 +29,7 @@
#include <QThread>
#include "Media.h"
#include "VLCMediaPlayer.h"
#include "Image.h"
......@@ -59,8 +60,13 @@ public:
* Return the length (duration) of a Media
*/
qint64 getLength();
/**
* Return the current time of the media
*/
qint64 getTime();
/**
* Change the current time of the media
*/
void setTime( qint64 time );
/**
......@@ -72,6 +78,7 @@ public:
virtual void pause();
virtual void stop();
void setDrawable( WId handle );
LibVLCpp::MediaPlayer* mediaPlayer() { return m_vlcMediaPlayer; }
private:
QImage* m_snapshot;
......
......@@ -36,6 +36,7 @@ MediaPlayer::MediaPlayer( Media* media, bool playStop /* = true*/ )
// Register the callback
libvlc_event_attach( p_em, libvlc_MediaPlayerSnapshotTaken, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, callbacks, this, m_ex );
}
/**
......@@ -62,7 +63,9 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
// case libvlc_MediaPlayerBackward:
// case libvlc_MediaPlayerEndReached:
// case libvlc_MediaPlayerEncounteredError:
// case libvlc_MediaPlayerTimeChanged:
case libvlc_MediaPlayerTimeChanged:
self->emit timeChanged();
break;
// case libvlc_MediaPlayerPositionChanged:
// case libvlc_MediaPlayerSeekableChanged:
// case libvlc_MediaPlayerPausableChanged:
......
......@@ -59,6 +59,7 @@ namespace LibVLCpp
signals:
void snapshotTaken();
void timeChanged();
};
}
......
......@@ -3,7 +3,7 @@
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarrire <geoffroylaca@gmail.com>
* Authors: Geoffroy Lacarrière <geoffroylaca@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -79,4 +79,17 @@ void PreviewWidget::dropEvent( QDropEvent* event )
m_currentMedia->setupMedia();
m_currentMedia->setDrawable( m_ui->clipRenderWidget->winId() );
m_currentMedia->play();
connect( m_currentMedia->mediaPlayer(),
SIGNAL( timeChanged() ),
this,
SLOT( videoTimeChanged() ) );
}
void PreviewWidget::videoTimeChanged()
{
if ( m_currentMedia )
{
m_ui->seekSlider->setMaximum( m_currentMedia->getLength() / 1000 );
m_ui->seekSlider->setSliderPosition( m_currentMedia->getTime() / 1000 );
}
}
......@@ -3,7 +3,7 @@
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarrire <geoffroylaca@gmail.com>
* Authors: Geoffroy Lacarrière <geoffroylaca@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -45,6 +45,9 @@ protected:
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event );
private slots:
void videoTimeChanged();
private:
Ui::PreviewWidget* m_ui;
InputMedia* m_currentMedia;
......
......@@ -70,7 +70,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QSlider" name="horizontalSlider">
<widget class="QSlider" name="seekSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment