Пример #1
0
/*#
void LayerSound::playSound(int frame) {
	for(int i=0; i < sound.size(); i++) {
		if (frame == framesPosition.at(i)) {
			if (sound.at(i) != NULL && visible) sound[i]->play();
		}
	}
}
#*/
void LayerSound::playSound(int frame,int fps)
{
    //QSettings settings("Pencil","Pencil");
    //int fps = settings.value("fps").toInt();

    for (int i = 0; i < sound.size(); ++i)
    {
        Phonon::MediaObject* media = sound.at(i);
        if (media != NULL && visible)
        {
            int position = framesPosition.at(i);
            if (frame < position)
            {
                media->stop();
            }
            else
            {
                Phonon::AudioOutput* audioOutput = NULL;
                if (outputDevices.size() <= i)
                {
                    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
                    outputDevices.push_back(audioOutput);
                }
                else
                {
                    audioOutput = outputDevices.at(i);
                }

                int offsetInMs = floor((frame - position) * float(1000) / fps);
                if (media->state() == Phonon::PlayingState)
                {
                    if (fabs((float)media->currentTime() - offsetInMs) > 500.0f)
                        media->seek(offsetInMs);
                }
                else
                {
                    if (frame > position)
                    {
                        media->pause();
                        media->seek(offsetInMs);
                    }
                    if (offsetInMs < soundSize[i])
                    {
                        Phonon::createPath(media, outputDevices.at(i));
                        media->play();
                    }
                }
            }
        }
    }
}
Пример #2
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);
}
Пример #3
0
 void VideoWidget::stop()
 {
     Phonon::MediaObject* mo = player->media0bject();
     if (mo->state() == Phonon::PausedState)
     {
         mo->seek(0);
         mo->stop();
     }
     else
     {
         mo->stop();
     }
 }
Пример #4
0
void PlayerManager::play(const FileHandle &file)
{
    if(!m_setup)
        setup();

    if(!m_media[0] || !m_media[1] || !m_playlistInterface)
        return;

    stopCrossfade();

    // The "currently playing" media object.
    Phonon::MediaObject *mediaObject = m_media[m_curOutputPath];
    
    if(file.isNull()) {
        if(paused())
            mediaObject->play();
        else if(playing()) {
            mediaObject->seek(0);
            emit seeked(0);
        }
        else {
            m_playlistInterface->playNext();
            m_file = m_playlistInterface->currentFile();

            if(!m_file.isNull())
            {
                mediaObject->setCurrentSource(KUrl::fromPath(m_file.absFilePath()));
                mediaObject->play();

                emit signalItemChanged(m_file);
            }
        }
    }
    else {
        mediaObject->setCurrentSource(KUrl::fromPath(file.absFilePath()));
        mediaObject->play();

        if(m_file != file)
            emit signalItemChanged(file);

        m_file = file;
    }

    // Our state changed handler will perform the follow up actions necessary
    // once we actually start playing.
}