Commit 1f8cf700 authored by Yann Boucher's avatar Yann Boucher
Browse files

bad apple linux fix

parent ec64f451
Pipeline #79776 passed with stages
in 17 seconds
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>Cellulut</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<property name="sizePolicy"> <property name="sizePolicy">
......
...@@ -720,9 +720,8 @@ void MainWindow::play_bad_apple() ...@@ -720,9 +720,8 @@ void MainWindow::play_bad_apple()
static bool bad_apple_connected; static bool bad_apple_connected;
#ifdef BAD_APPLE_AUDIO #ifdef BAD_APPLE_AUDIO
static QMediaPlayer bad_apple_player; static QMediaPlayer bad_apple_player;
#else
static QElapsedTimer bad_apple_elapsed;
#endif #endif
static QElapsedTimer bad_apple_elapsed;
QFile f("extras/bad_apple.json"); QFile f("extras/bad_apple.json");
if (!f.open(QFile::ReadOnly | QFile::Text)) if (!f.open(QFile::ReadOnly | QFile::Text))
...@@ -744,7 +743,11 @@ void MainWindow::play_bad_apple() ...@@ -744,7 +743,11 @@ void MainWindow::play_bad_apple()
bad_apple_timer.callOnTimeout([this] bad_apple_timer.callOnTimeout([this]
{ {
#ifdef BAD_APPLE_AUDIO #ifdef BAD_APPLE_AUDIO
unsigned frame_idx = bad_apple_player.position()/(1000.f/30); unsigned frame_idx;
if (bad_apple_player.state() == QMediaPlayer::PlayingState)
frame_idx = bad_apple_player.position()/(1000.f/30);
else
frame_idx = bad_apple_elapsed.elapsed()/(1000.f/30);
#else #else
unsigned frame_idx = bad_apple_elapsed.elapsed()/(1000.f/30); unsigned frame_idx = bad_apple_elapsed.elapsed()/(1000.f/30);
#endif #endif
...@@ -786,9 +789,9 @@ void MainWindow::play_bad_apple() ...@@ -786,9 +789,9 @@ void MainWindow::play_bad_apple()
bad_apple_player.play(); bad_apple_player.play();
#else #else
QMessageBox::information(this, "", "Music functionnality is only available with Qt 5"); QMessageBox::information(this, "", "Music functionnality is only available with Qt 5");
bad_apple_elapsed.start();
#endif #endif
bad_apple_elapsed.start();
bad_apple_timer.start(11); bad_apple_timer.start(11);
statusBar()->showMessage("Original : \"Bad Apple!!\" feat. Nomico by Alstroemeria Records", 60000); statusBar()->showMessage("Original : \"Bad Apple!!\" feat. Nomico by Alstroemeria Records", 60000);
} }
......
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