1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 16:31:58 +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
commit 980ee97c97
3 changed files with 28 additions and 3 deletions

View File

@ -481,16 +481,19 @@ AudioOutput::seek( qint64 milliseconds )
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 )
{
// tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking" << milliseconds << "msec";
libvlc_media_player_set_time( m_vlcPlayer, milliseconds );
setCurrentTime( milliseconds );
}
else
{
qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
float position = float(float(milliseconds) / duration);
libvlc_media_player_set_position(m_vlcPlayer, position);
tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking via position" << position << "pos";

View File

@ -33,6 +33,7 @@ SeekSlider::SeekSlider( QWidget* parent )
, TomahawkUtils::DpiScaler( this )
, m_timeLine( 0 )
, m_acceptWheelEvents( true )
, m_isScrubbing( false )
{
setStyleSheet( QString(
"QSlider::groove:horizontal {"
@ -72,6 +73,8 @@ SeekSlider::mousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton )
{
m_isScrubbing = true;
QMouseEvent eventSwap( QEvent::MouseButtonRelease, event->pos(), event->globalPos(), Qt::MidButton, Qt::MidButton, event->modifiers() );
QSlider::mousePressEvent( &eventSwap );
}
@ -107,3 +110,20 @@ SeekSlider::wheelEvent( QWheelEvent* event )
}
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:
void mousePressEvent( QMouseEvent* event );
void mouseMoveEvent( QMouseEvent* event );
void wheelEvent( QWheelEvent* event );
private:
QTimeLine* m_timeLine;
bool m_acceptWheelEvents;
bool m_isScrubbing;
};
#endif // SEEKSLIDER_H