changeset 384:be237d380f5f macness

importITunesAudio() now sets the SV playback position too
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Mon, 18 Oct 2010 15:23:21 +0100
parents abb9c3dedec2
children a555be0ad78f
files main/MainWindow.cpp osx/svitunes.h osx/svitunes.mm
diffstat 3 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Mon Oct 18 14:44:28 2010 +0100
+++ b/main/MainWindow.cpp	Mon Oct 18 15:23:21 2010 +0100
@@ -2163,6 +2163,7 @@
 void
 MainWindow::importITunesAudio()
 {
+    m_iTunes->resetPlayerState();
     QStringList nowPlaying = m_iTunes->getNowPlaying();
     QString path = nowPlaying.at(0);
     QString genre = (nowPlaying.size() > 1) ? nowPlaying.at(1) : "";
@@ -2175,6 +2176,10 @@
                   tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
     }else{
         m_iTunes->updatePlayerState();
+        RealTime playerPos = RealTime::fromSeconds(m_iTunes->playerPos());
+        unsigned long positionFrames = RealTime::realTime2Frame(playerPos, getMainModel()->getSampleRate());
+        m_viewManager->setGlobalCentreFrame(positionFrames);
+        m_viewManager->setPlaybackFrame(positionFrames);
     }
     }
 }
--- a/osx/svitunes.h	Mon Oct 18 14:44:28 2010 +0100
+++ b/osx/svitunes.h	Mon Oct 18 15:23:21 2010 +0100
@@ -39,6 +39,10 @@
         // Returns a list containing [posixpath, genre]
         QStringList getNowPlaying();
         
+        // When importing a fresh track we don't want the old cached playback position.
+        // We can't simply update player position every time, since it only gets reported if playing.
+        void resetPlayerState();
+        
         // Queries iTunes about player state and stores results locally
         void updatePlayerState();
     
--- a/osx/svitunes.mm	Mon Oct 18 14:44:28 2010 +0100
+++ b/osx/svitunes.mm	Mon Oct 18 15:23:21 2010 +0100
@@ -155,3 +155,7 @@
 unsigned int ITunesSVRemote::playerPos(){
     return m_playerPos;
 }
+
+void ITunesSVRemote::resetPlayerState(){
+    m_playerPos = 0;
+}