void Chaser::setTotalDuration(quint32 msec) { if (durationMode() == Chaser::Common) { int stepsCount = m_steps.count(); if (stepsCount == 0) stepsCount = 1; setDuration(msec / stepsCount); } else { // scale all the Chaser steps to resize // to the desired duration double dtDuration = (double)totalDuration(); for (int i = 0; i < m_steps.count(); i++) { uint origDuration = m_steps[i].duration; m_steps[i].duration = ((double)m_steps[i].duration * msec) / dtDuration; if(m_steps[i].hold) m_steps[i].hold = ((double)m_steps[i].hold * (double)m_steps[i].duration) / (double)origDuration; m_steps[i].fadeIn = m_steps[i].duration - m_steps[i].hold; if (m_steps[i].fadeOut) m_steps[i].fadeOut = ((double)m_steps[i].fadeOut * (double)m_steps[i].duration) / (double)origDuration; } } emit changed(this->id()); }
void Home::setCurrentTime(int time) { QString timeString; // time no formato "00:00" para o label int remainingTime = totalDuration() - time; if (remainingTime != 0){ int minutes = remainingTime / 60; int seconds = remainingTime % 60; QString minutesString = minutes < 10? "0" + QString::number(minutes): QString::number(minutes); QString secondsString = seconds < 10? "0" + QString::number(seconds): QString::number(seconds); timeString = minutesString + ":" + secondsString; }else{ timeString = "00:00"; } lTime->setText(timeString); if (progress->maximum() != 0){ _currentTime = time; progress->setValue(time); lPercent->setText(QString::number((float)(progress->value()) / progress->maximum() * 100, 'f', 2) + "%"); }else { lPercent->setText("0%"); } }
void Segments::calculateTotalDuration(){ double duration = 0; Segment * segment; for (int i = 0;i < segments.size();++i){ segment = segments.at(i).data(); duration+=segment->duration(); } emit totalDuration(duration); }
void QAbstractAnimationJob::start() { if (m_state == Running) return; if (QQmlEnginePrivate::designerMode()) { if (state() != Stopped) { m_currentTime = duration(); m_totalCurrentTime = totalDuration(); setState(Running); setState(Stopped); } } else { setState(Running); } }
void QuickTimeDecoder::seekToTime(Audio::Timestamp time) { // TODO: Audio-only seeking (or really, have QuickTime sounds) if (_videoStreamIndex < 0) error("Audio-only seeking not supported"); // Try to find the last frame that should have been decoded uint32 frame = 0; Audio::Timestamp totalDuration(0, _streams[_videoStreamIndex]->time_scale); bool done = false; for (int32 i = 0; i < _streams[_videoStreamIndex]->stts_count && !done; i++) { for (int32 j = 0; j < _streams[_videoStreamIndex]->stts_data[i].count; j++) { totalDuration = totalDuration.addFrames(_streams[_videoStreamIndex]->stts_data[i].duration); if (totalDuration > time) { done = true; break; } frame++; } } seekToFrame(frame); }
void QuickTimeDecoder::seekToTime(Audio::Timestamp time) { // Use makeQuickTimeStream() instead if (_videoTrackIndex < 0) error("Audio-only seeking not supported"); // Try to find the last frame that should have been decoded uint32 frame = 0; Audio::Timestamp totalDuration(0, _tracks[_videoTrackIndex]->timeScale); bool done = false; for (int32 i = 0; i < _tracks[_videoTrackIndex]->timeToSampleCount && !done; i++) { for (int32 j = 0; j < _tracks[_videoTrackIndex]->timeToSample[i].count; j++) { totalDuration = totalDuration.addFrames(_tracks[_videoTrackIndex]->timeToSample[i].duration); if (totalDuration > time) { done = true; break; } frame++; } } seekToFrame(frame); }
void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState) { if (m_state == newState) return; if (m_loopCount == 0) return; State oldState = m_state; int oldCurrentTime = m_currentTime; int oldCurrentLoop = m_currentLoop; Direction oldDirection = m_direction; // check if we should Rewind if ((newState == Paused || newState == Running) && oldState == Stopped) { //here we reset the time if needed //we don't call setCurrentTime because this might change the way the animation //behaves: changing the state or changing the current value m_totalCurrentTime = m_currentTime = (m_direction == Forward) ? 0 : (m_loopCount == -1 ? duration() : totalDuration()); // Reset uncontrolled finish time and currentLoopStartTime for this run. m_uncontrolledFinishTime = -1; if (!m_group) m_currentLoopStartTime = m_totalCurrentTime; } m_state = newState; //(un)registration of the animation must always happen before calls to //virtual function (updateState) to ensure a correct state of the timer bool isTopLevel = !m_group || m_group->isStopped(); if (oldState == Running) { if (newState == Paused && m_hasRegisteredTimer) QQmlAnimationTimer::ensureTimerUpdate(); //the animation, is not running any more QQmlAnimationTimer::unregisterAnimation(this); } else if (newState == Running) { QQmlAnimationTimer::registerAnimation(this, isTopLevel); } //starting an animation qualifies as a top level loop change if (newState == Running && oldState == Stopped && !m_group) fireTopLevelAnimationLoopChanged(); RETURN_IF_DELETED(updateState(newState, oldState)); if (newState != m_state) //this is to be safe if updateState changes the state return; // Notify state change RETURN_IF_DELETED(stateChanged(newState, oldState)); if (newState != m_state) //this is to be safe if updateState changes the state return; switch (m_state) { case Paused: break; case Running: { // this ensures that the value is updated now that the animation is running if (oldState == Stopped) { m_currentLoop = 0; if (isTopLevel) { // currentTime needs to be updated if pauseTimer is active RETURN_IF_DELETED(QQmlAnimationTimer::ensureTimerUpdate()); RETURN_IF_DELETED(setCurrentTime(m_totalCurrentTime)); } } } break; case Stopped: // Leave running state. int dura = duration(); if (dura == -1 || m_loopCount < 0 || (oldDirection == Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * m_loopCount)) || (oldDirection == Backward && oldCurrentTime == 0)) { finished(); } break; } }
int MonitorData::avgScorePerSecond() // gameScore/gameDuration { return totalScore() / totalDuration(); }
int MonitorData::avgDurationPerBall() // sigma(secondsPerBall)/secondsPerBall.length { int total = totalDuration(); return total / m_balls.size(); }