Exemplo n.º 1
0
void TrackLyricsActor::handleNotification(const VisualNotification& aNotification) {

	//VisualActor::handleNotification(aNotification); // debug
	
	VisualString trackLyricsStr;
	const VisualString missingValueString("missing value"); // "missing value" is literally sent with streams that do not convey any lyrics

	VisualNotificationKey notificationKey = aNotification.getKey();
	
	switch (notificationKey) {
		case kAudioMetadataIsAvailableMsg:
			VisualDataStore::createLyricsOfCurrentTrack();
			break;
		case kLyricsAreAvailableMsg:
			trackLyricsStr = VisualDataStore::getLyricsOfCurrentTrack();
			if (trackLyricsStr.getNumberOfNonWhitespaceCharacters() > 0 && trackLyricsStr != missingValueString) {
				OSStatus status = this->trackLyrics->makeTextureOfTrackLyrics(trackLyricsStr);
				if (status == noErr) {
					this->trackLyrics->calcPositionOnScreen();
					VisualNotification::post(kLyricsTextureIsAvailableMsg);
				}
			}
			break;
		case kLyricsTextureIsAvailableMsg:
			this->textureOfCurrentTrackLyricsIsAvailable = true;
			this->trackLyrics->fadeIn(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeInTimeOnPlayInMS));
			break;
		case kAudioPlayStartedEvt:
			this->trackLyrics->clear();
			this->textureOfCurrentTrackLyricsIsAvailable = false;
			break;
		case kAudioPlayStoppedEvt:
			this->trackLyrics->clear();
			this->textureOfCurrentTrackLyricsIsAvailable = false;
			break;
		case kAudioPlayPausedEvt:
			this->trackLyrics->fadeOut(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeOutTimeOnPauseInMS), 0.15f);
			break;
		case kAudioPlayResumedEvt:
			this->trackLyrics->fadeIn(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeInTimeOnResumeInMS));
			break;
		case kAudioPlayReachedFadeOutTimeBeforeEndOfTrackEvt:
			this->trackLyrics->fadeOut(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeOutTimeBeforeEndOfTrackInMS));
			break;
		case kCanvasReshapeEvt:
			if (textureOfCurrentTrackLyricsIsAvailable == true) {
				this->trackLyrics->calcPositionOnScreen();
			}
			break;
		case kTrackInfoTextureChangedMsg:
			if (textureOfCurrentTrackLyricsIsAvailable == true) {
				this->trackLyrics->calcPositionOnScreen();
			}
			break;
		default:
			writeLog("unhandled Notification in TrackLyricsActor");
			break;
	}

}
Exemplo n.º 2
0
void TrackTitleActor::handleNotification(const VisualNotification& aNotification) {

	//VisualActor::handleNotification(aNotification); // debug
	
	VisualNotificationKey notificationKey = aNotification.getKey();
	
	switch (notificationKey) {
		case kAudioMetadataIsAvailableMsg:
			{
				const VisualString trackName = VisualDataStore::getNameOfCurrentTrack();
				if (trackName.getNumberOfNonWhitespaceCharacters() > 0) {
					OSStatus status = this->trackTitle->makeTextureOfTrackTitle(trackName);
					if (status == noErr) {
						this->trackTitle->calcPositionOnScreen();
						VisualDataStore::setValueInt(VisualConfiguration::kTrackInfoTextureHeight, this->trackTitle->getTrackInfoTextureHeightInPixels());
						VisualNotification::post(kTrackInfoTextureIsAvailableMsg);
					} else {
						VisualDataStore::setValueInt(VisualConfiguration::kTrackInfoTextureHeight, 0);
					}
					VisualNotification::post(kTrackInfoTextureChangedMsg);
				}
			}
			break;
		case kTrackInfoTextureIsAvailableMsg:
			this->textureOfCurrentTrackTitleIsAvailable = true;
			this->trackTitle->fadeIn(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeInTimeOnPlayInMS));
			break;
		case kAudioPlayStartedEvt:
			this->trackTitle->clear();
			this->textureOfCurrentTrackTitleIsAvailable = false;
			break;
		case kAudioPlayStoppedEvt:
			this->trackTitle->clear();
			this->textureOfCurrentTrackTitleIsAvailable = false;
			break;
		case kAudioPlayPausedEvt:
			this->trackTitle->pulsate();
			break;
		case kAudioPlayResumedEvt:
			this->trackTitle->fadeIn(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeInTimeOnResumeInMS));
			break;
		case kAudioPlayReachedFadeOutTimeBeforeEndOfTrackEvt:
			this->trackTitle->fadeOut(VisualDataStore::getPreferenceValueInt(VisualConfiguration::kFadeOutTimeBeforeEndOfTrackInMS));
			break;
		case kCanvasReshapeEvt:
			this->trackTitle->calcPositionOnScreen();
			VisualDataStore::setValueInt(VisualConfiguration::kTrackInfoTextureHeight, this->trackTitle->getTrackInfoTextureHeightInPixels());
			break;
		default:
			writeLog("unhandled Notification in TrackTitleActor");
			break;
	}

}