当前位置: 首页>>代码示例>>C++>>正文


C++ Playlist::requestUpdate方法代码示例

本文整理汇总了C++中Playlist::requestUpdate方法的典型用法代码示例。如果您正苦于以下问题:C++ Playlist::requestUpdate方法的具体用法?C++ Playlist::requestUpdate怎么用?C++ Playlist::requestUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Playlist的用法示例。


在下文中一共展示了Playlist::requestUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doCommand


//.........这里部分代码省略.........
					muted = ! muted;
					Serial.print(F("muting "));
					Serial.println(muted ? F("on") : F("off"));
				}
				else {
					playlist->setPortamento(firstParameterChar == 'P');
				}
				parameters++;
				if(*parameters == '\0') {
					return true;
				}
			}
			playlist->setVolume(number(parameters, DEFAULT_VOLUME)); // noParam form will set volume to default
			break;

		case '*': // autoplay
			if(noParameters) {
				Serial.println(F("autoplay now"));
				immediateAutoplayStart();
				return false; // don't show prompt
			}
			else {
				doAutoplaySettingsCommand(playlist, parameters);
			}
			break;

		case '|':
			Serial.println(F("limit"));
			playlist->setAutoplayChirpLimit(number(parameters, PLAYLIST_CAPACITY));
			break;

		case '^': // times
			Serial.println(F("time"));
			if(noParameters) {
				return ! playerLink.fetchTimeNow();
			}
			else if(firstParameterChar == '-') {
				adjustTimeSeconds(-number(&parameters[1]));
			}
			else if(firstParameterChar == '+') {
				adjustTimeSeconds(number(&parameters[1]));
			}
			if(stringToSeconds(parameters)) {
				setTimeUTC(parameters);
			}
			break;

		case '#': // scripts
			if(noParameters) {
				if( ! playlist->requestUpdate()) {
					Serial.println(F("no script"));
				}
			}
			else {
				if(length == 2) {
					if(firstParameterChar == '?') { // #? to print current playlist in script format
						playlist->printAsScript();
					}
					else {
						playlist->setUpdateFlags(number(parameters));
					}
				}
				else {
					playlist->setScriptAddress(parameters);
				}
			}
			break;

		case '/': // run named script, or update all playlists with scripts
			Serial.println(F("run"));
			if(noParameters) {
				Playlists::updateAll(false); // false => not conditional on playlist flags
			}
			else {
				return ! playerLink.fetchScript(-1, parameters); // -1 signals is general script, not one for a particular playlist
			}
			break;

		case '=': // invoke trigger from the command line
			Trigger::trigger(parameters);
			break;

		case '-':
			inactivityTrigger.setWaitSeconds(number(parameters));
			break;

		case '%': // comment line; ignore
			break;

		default:
			if(isAChirpCode(command)) {
				playlist->add(command);
			}
			else {
				Serial.println(F("uh?"));
			}
			break;
	}
	return true;
}
开发者ID:RobertLeyland,项目名称:chirpino,代码行数:101,代码来源:Commands.cpp

示例2: autoplayLoop

void autoplayLoop() {
    static int32_t then; // now field from last time in loop

    int32_t now = timeNowSecondsSinceMidnight();
    int16_t nowMinute = now / 60;

    // start any new autoplays
    if(nowMinute > then / 60 || autoplayNow) {
        // its a new minute; check the playlists to see if any due to start autoplaying this minute
        autoplayNow = false;

        for(int ix = 0; ix < N_PLAYLISTS; ix++) {
            Playlist *p = Playlists::playlist(ix);

            if(p->nChirps > 0 && p->autoplayCount == 0) { // only check if playlist has chirps and isn't already playing
                AutoplayStructure settings;
                p->getAutoplaySettings(&settings);

                int16_t startMinute = settings.startMinute;

                // run through all start times for playlist
                // doesn't play before initial start time and doesn't continue repeating past midnight
                for(uint8_t n = 0; n < settings.count && nowMinute >= startMinute && startMinute < minutesInOneDay; n++) {
                    if(startMinute == nowMinute) {
                        if(p->getUpdateFlags() & UPDATE_WHEN_AUTOPLAY) {
                            p->requestUpdate();
                        }

                        // setting non-zero count makes autoplay active
                        p->autoplayCount = min(settings.maxChirps, p->nChirps); 
                        p->autoplayTimeSeconds = 0; // play as soon as possible
                        break;
                    }
                    startMinute += settings.repeatMinutes;
                }
            }
        }
    }

    // autoplay up to one chirp per new second

    if(now > then) {
        // it's a new second

        // first check to see if current playlist is being autoplayed from the command line
        if(immediateAutoplayCount > 0 && now >= immediateAutoplayTimeSeconds) {
            Playlist *p = Playlists::currentPlaylist();

            if(p->playSequenced()) {
                immediateAutoplayCount--;
                immediateAutoplayTimeSeconds = now + p->getInterval();
            }
            else {
                // empty playlist: turn off
                immediateAutoplayCount = 0;
            }
            if(immediateAutoplayCount == 0) {
                showPrompt();
            }
        }
        else {
            // check any timed autoplaying playlists for any due to play now
            for(int ix = 0; ix < N_PLAYLISTS; ix++) {
                Playlist *p = Playlists::playlist(ix);

                if(p->autoplayCount > 0 && now >= p->autoplayTimeSeconds && p->awaitingUpdate == NOT_AWAITING_UPDATE) {
                    if(p->playSequenced()) {
                        p->autoplayCount--;
                        p->autoplayTimeSeconds = now + p->getInterval();
                        break; // only one play per vsit to this function
                    }
                    else {
                        p->autoplayCount = 0; // empty playlist (shouldn't happen here)
                    }
                }
            }
        }
    }

    then = now;
}
开发者ID:RobertLeyland,项目名称:chirpino,代码行数:81,代码来源:Times.cpp


注:本文中的Playlist::requestUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。