Пример #1
0
QVariantMap TrackListDBusHandler::GetMetadata(int position)
{
    QVariantMap ret;
    if (position < 0 || position > m_tracks.size()-1) {
        return ret;
    }

    //FIXME: ugly and slow
    Phonon::MediaObject mediaObject;
    mediaObject.setCurrentSource(m_tracks[position]);

    QMultiMap<QString, QString> stringMap = mediaObject.metaData();
    QMultiMap<QString, QString>::const_iterator i = stringMap.constBegin();

    while (i != stringMap.constEnd()) {
        bool number = false;
        int value = i.value().toInt(&number);

        //tracknumber always string, according to MPRIS spec
        if (number && (i.key().toLower() != "tracknumber")) {
            ret[i.key().toLower()] = value;
        } else {
            ret[i.key().toLower()] = QVariant(i.value());
        }
        ++i;
    }

    ret["time"] = mediaObject.totalTime()/1000;

    ret["location"] = mediaObject.currentSource().url().toString();
    return ret;
}
void UBGraphicsVideoItemDelegate::updateTicker(qint64 time)
{
    Phonon::MediaObject* media = delegated()->mediaObject();
    mVideoControl->totalTimeChanged(media->totalTime());

    mVideoControl->updateTicker(time);
}
Пример #3
0
void PlayerManager::seekBack()
{
    Phonon::MediaObject *mediaObject = m_media[m_curOutputPath];
    const qint64 total = mediaObject->totalTime();
    const qint64 newtime = mediaObject->currentTime() - total / 100;
    const qint64 seekTo = qMax(qint64(0), newtime);

    stopCrossfade();
    mediaObject->seek(seekTo);
    emit seeked(seekTo);
}
Пример #4
0
void Video::getVideoInformation()
{
    QFileInfo fileInfo(videoPath);
    videoName = fileInfo.fileName();

    Phonon::MediaObject mediaObject;
    mediaObject.setCurrentSource(videoPath);
    // TODO: This doesn't work. Media needs to be loaded
    qint64 totalMs = mediaObject.totalTime();
    qint64 totSeconds = totalMs / 1000;
    qint64 seconds = totSeconds % 60;
    qint64 totMinutes = totSeconds / 60;
    qint64 minutes = totMinutes % 60;
    qint64 hours = totMinutes / 60;

    videoTotalTime = QTime(hours, minutes, seconds);
    qDebug() << videoTotalTime;
}
Пример #5
0
void LayerSound::loadSoundAtFrame(QString filePathString, int frameNumber)
{
//	if (getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber);
    int index = getIndexAtFrame(frameNumber);
    if (index == -1)
        addImageAtFrame(frameNumber);
    index = getIndexAtFrame(frameNumber);

    QFileInfo fi(filePathString);
    if (fi.exists())
    {
//		sound[index] = new QSound(filePathString, NULL);
        Phonon::MediaObject* media = new Phonon::MediaObject();
        connect(media, SIGNAL(totalTimeChanged(qint64)), this, SLOT(addTimelineKey(qint64)));
        media->setCurrentSource(filePathString);
        // quick and dirty trick to calculate soundSize
        // totalTime() return a value only after a call to media.play()
        //  ( and when signal totaltimechanged is emitted totalTime() returns the correct value )
        Phonon::AudioOutput* audioOutput;
        audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
        Phonon::createPath(media, audioOutput);
        media->play();
        media->stop();
        soundSize[index] = media->totalTime(); // totalTime() returns 0 now
        sound[index] = media;
        soundFilepath[index] = filePathString;
        framesFilename[index] = fi.fileName();
        framesModified[index] = true;
    }
    else
    {
        sound[index] = NULL;
        soundFilepath[index] = "Wrong file";
        framesFilename[index] = "Wrong file" + filePathString;
    }
}