Skip to content

Commit

Permalink
non-linear speed control
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jun 30, 2013
1 parent 5e1e9b5 commit b39a0bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ The default is Qt's paint engine.
- R: switch aspect ratio
- M: mute on/off
- Up / Down: volume + / -
- Ctrl+Up/Down: speed + / -
- -> / <-: seek forward / backward
- Drag and drop a media file to player

Expand Down
25 changes: 19 additions & 6 deletions src/EventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,16 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event)
case Qt::Key_Up: {
AudioOutput *ao = player->audio();
if (modifiers == Qt::ControlModifier) {
qDebug("increase speed");
if (ao && ao->isAvailable()) {
qDebug("set speed %.2f =>> %.2f", ao->speed(), ao->speed()+0.1);
ao->setSpeed(ao->speed() + 0.05);
qreal s = ao->speed();
if (s < 1.4)
s += 0.02;
else
s += 0.05;
if (qAbs<qreal>(s-1.0) <= 0.01)
s = 1.0;
qDebug("set speed %.2f =>> %.2f", ao->speed(), s);
ao->setSpeed(s);
} else {
//clock speed
}
Expand All @@ -236,10 +242,17 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event)
case Qt::Key_Down: {
AudioOutput *ao = player->audio();
if (modifiers == Qt::ControlModifier) {
qDebug("decrease speed");
qreal s = ao->speed();
if (s < 1.4)
s -= 0.02;
else
s -= 0.05;
if (qAbs<qreal>(s-1.0) <= 0.01)
s = 1.0;
s = qMax(s, 0.0);
if (ao && ao->isAvailable()) {
qDebug("set speed %.2f =>> %.2f", ao->speed(), ao->speed()-0.1);
ao->setSpeed(qMax(ao->speed() - 0.05, 0.0));
qDebug("set speed %.2f =>> %.2f", ao->speed(), s);
ao->setSpeed(s);
} else {
//clock speed
}
Expand Down

0 comments on commit b39a0bb

Please sign in to comment.