Tune WinAmpTuneController::getTune(const HWND &hWnd) { Tune tune = Tune(); int position = (int)SendMessage(hWnd, WM_WA_IPC, 0, IPC_GETLISTPOS); if (position != -1) { if (hWnd && SendMessage(hWnd,WM_WA_IPC,0,IPC_ISPLAYING) == 1) { QPair<bool, QString> trackpair(getTrackTitle(hWnd)); if (!trackpair.first) { // getTrackTitle wants us to retry in a few ms... int interval = AntiscrollInterval; if (++antiscrollCounter_ > 10) { antiscrollCounter_ = 0; interval = NormInterval; } setInterval(interval); return Tune(); } antiscrollCounter_ = 0; tune.setName(trackpair.second); tune.setURL(trackpair.second); tune.setTrack(QString::number(position + 1)); tune.setTime(SendMessage(hWnd, WM_WA_IPC, 1, IPC_GETOUTPUTTIME)); } } return tune; }
Tune AimpTuneController::getTune() const { HANDLE aFile=OpenFileMapping(FILE_MAP_READ, TRUE, AIMP_REMOTE_CLASS); PAIMPRemoteFileInfo aInfo = (PAIMPRemoteFileInfo)MapViewOfFile(aFile, FILE_MAP_READ, 0, 0, AIMPRemoteAccessMapFileSize); if (aInfo != NULL) { wchar_t *str = (wchar_t *)((char*)aInfo + sizeof(*aInfo)); QString album = QString::fromWCharArray(str, aInfo->AlbumLength); str += aInfo->AlbumLength; QString artist = QString::fromWCharArray(str, aInfo->ArtistLength); str += aInfo->ArtistLength + aInfo->DateLength; QString url = QString::fromWCharArray(str, aInfo->FileNameLength); str += aInfo->FileNameLength + aInfo->GenreLength; QString title = QString::fromWCharArray(str, aInfo->TitleLength); unsigned long trackNumber = aInfo->TrackNumber; unsigned long time = aInfo->Duration; Tune tune = Tune(); if (!url.isEmpty()) { if (!title.isEmpty()) { tune.setName(title); } else { int index = url.replace("/", "\\").lastIndexOf("\\"); if (index > 0) { QString filename = url.right(url.length()-index-1); index = filename.lastIndexOf("."); title = (index > 0) ? filename.left(index) : filename; } else { title = url; } tune.setName(title); } if (trackNumber > 0) { tune.setTrack(QString::number(trackNumber)); } if (time > 0) { tune.setTime((uint)time); } if (!artist.isEmpty()) { tune.setArtist(artist); } if (!album.isEmpty()) { tune.setAlbum(album); } tune.setURL(url); } return tune; } UnmapViewOfFile(aInfo); CloseHandle(aFile); return Tune(); }