1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-15 10:33:59 +02:00

Merge pull request #332 from tmwoz/master

Fix for next track not getting triggered when seeking to/past the end with a mouse
This commit is contained in:
Christian Muehlhaeuser
2016-04-12 15:45:07 +02:00
3 changed files with 28 additions and 3 deletions

View File

@@ -481,16 +481,19 @@ AudioOutput::seek( qint64 milliseconds )
return; return;
} }
qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
// for some tracks, seeking to an end seems not to work correctly with libvlc
// (tracks enter a random and infinite loop) - this is a temporary fix for that
if (duration == milliseconds)
milliseconds -= 1;
if ( m_seekable ) if ( m_seekable )
{ {
// tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking" << milliseconds << "msec";
libvlc_media_player_set_time( m_vlcPlayer, milliseconds ); libvlc_media_player_set_time( m_vlcPlayer, milliseconds );
setCurrentTime( milliseconds ); setCurrentTime( milliseconds );
} }
else else
{ {
qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
float position = float(float(milliseconds) / duration); float position = float(float(milliseconds) / duration);
libvlc_media_player_set_position(m_vlcPlayer, position); libvlc_media_player_set_position(m_vlcPlayer, position);
tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking via position" << position << "pos"; tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking via position" << position << "pos";

View File

@@ -33,6 +33,7 @@ SeekSlider::SeekSlider( QWidget* parent )
, TomahawkUtils::DpiScaler( this ) , TomahawkUtils::DpiScaler( this )
, m_timeLine( 0 ) , m_timeLine( 0 )
, m_acceptWheelEvents( true ) , m_acceptWheelEvents( true )
, m_isScrubbing( false )
{ {
setStyleSheet( QString( setStyleSheet( QString(
"QSlider::groove:horizontal {" "QSlider::groove:horizontal {"
@@ -72,6 +73,8 @@ SeekSlider::mousePressEvent( QMouseEvent* event )
{ {
if ( event->button() == Qt::LeftButton ) if ( event->button() == Qt::LeftButton )
{ {
m_isScrubbing = true;
QMouseEvent eventSwap( QEvent::MouseButtonRelease, event->pos(), event->globalPos(), Qt::MidButton, Qt::MidButton, event->modifiers() ); QMouseEvent eventSwap( QEvent::MouseButtonRelease, event->pos(), event->globalPos(), Qt::MidButton, Qt::MidButton, event->modifiers() );
QSlider::mousePressEvent( &eventSwap ); QSlider::mousePressEvent( &eventSwap );
} }
@@ -107,3 +110,20 @@ SeekSlider::wheelEvent( QWheelEvent* event )
} }
event->ignore(); event->ignore();
} }
void
SeekSlider::mouseMoveEvent( QMouseEvent* event )
{
if (!m_isScrubbing)
return;
// disable further scrubbing when we're past the slider's right margin
if (event->pos().x() > width())
{
m_isScrubbing = false;
return;
}
QSlider::mouseMoveEvent(event);
}

View File

@@ -44,11 +44,13 @@ public slots:
protected: protected:
void mousePressEvent( QMouseEvent* event ); void mousePressEvent( QMouseEvent* event );
void mouseMoveEvent( QMouseEvent* event );
void wheelEvent( QWheelEvent* event ); void wheelEvent( QWheelEvent* event );
private: private:
QTimeLine* m_timeLine; QTimeLine* m_timeLine;
bool m_acceptWheelEvents; bool m_acceptWheelEvents;
bool m_isScrubbing;
}; };
#endif // SEEKSLIDER_H #endif // SEEKSLIDER_H