# HG changeset patch # User Dan Stowell # Date 1287411801 -3600 # Node ID be237d380f5ff916fce3a19ffe01bfab9e5835cc # Parent abb9c3dedec266005836a345ea04d9e9808ea88f importITunesAudio() now sets the SV playback position too diff -r abb9c3dedec2 -r be237d380f5f main/MainWindow.cpp --- 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("File open failed

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); } } } diff -r abb9c3dedec2 -r be237d380f5f osx/svitunes.h --- 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(); diff -r abb9c3dedec2 -r be237d380f5f osx/svitunes.mm --- 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; +}