Beispiel #1
0
void MusicControl::updateTime()
{
    long len = m_c->length();
    m_seekSlider->setMaximum(len);
    long pos = m_c->position();
    m_seekSlider->setValue(pos);
    QString timeString;
    if (pos || len)
    {
        int sec = pos/1000;
        int min = sec/60;
        int hour = min/60;
        int msec = pos;

        QTime playTime(hour%60, min%60, sec%60, msec%1000);
        sec = len / 1000;
        min = sec / 60;
        hour = min / 60;
        msec = len;

        QTime stopTime(hour%60, min%60, sec%60, msec%1000);
        QString timeFormat = "m:ss";

        if(hour > 0)
            timeFormat = "h:mm:ss";

        timeString = playTime.toString(timeFormat);

        if(len)
            timeString += " / " + stopTime.toString(timeFormat);
    }
    m_timeLabel->setText(timeString);
}
Beispiel #2
0
// show playing time (left or elapsed just click on the label to switch)
void Player::updateTime()
{
    long len = videoPlayer->mediaObject()->totalTime();
    long pos = videoPlayer->mediaObject()->currentTime();
    timeSlider->setValue(pos);
    QString timeString;    
    if (pos || len)
    {
        int sec = pos/1000;
        int min = sec/60;
        int hour = min/60;
        int msec = pos;

        QTime playTime(hour%60, min%60, sec%60, msec%1000);
        sec = len / 1000;
        min = sec / 60;
        hour = min / 60;
        msec = len;

        QTime stopTime(hour%60, min%60, sec%60, msec%1000);
        QString timeFormat = "hh:mm:ss";
        
        timeString = playTime.toString(timeFormat);
    }
    timeLabel->setText(timeString);
}