本文整理汇总了C++中QMediaPlayer::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QMediaPlayer::setPosition方法的具体用法?C++ QMediaPlayer::setPosition怎么用?C++ QMediaPlayer::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMediaPlayer
的用法示例。
在下文中一共展示了QMediaPlayer::setPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playSegment
void WaveformView::playSegment(LipsyncPhrase *fPhrase, LipsyncWord *fWord, LipsyncPhoneme *fPhoneme, int32 fScrubFrame)
{
bool playSegment = false;
QMediaPlayer *audioPlayer = fDoc->GetAudioPlayer();
int32 startFrame;
fAudioStopFrame = -1;
if (audioPlayer)
{
if (fPhrase)
{
playSegment = true;
startFrame = fPhrase->fStartFrame;
fAudioStopFrame = fPhrase->fEndFrame + 1;
}
else if (fWord)
{
playSegment = true;
startFrame = fWord->fStartFrame;
fAudioStopFrame = fWord->fEndFrame + 1;
}
else if (fPhoneme)
{
playSegment = true;
startFrame = fPhoneme->fFrame;
fAudioStopFrame = startFrame + 1;
}
if (playSegment)
{
float f = ((real)startFrame / (real)fDoc->Fps()) * 1000.0f;
audioPlayer->setPosition(PG_ROUND(f));
audioPlayer->play();
emit(frameChanged(fScrubFrame));
}
}
}
示例2: QGraphicsPixmapItem
Bullet::Bullet()
:QObject(),
QGraphicsPixmapItem()
{
setPixmap(QPixmap(":/images/rocket.png"));
QTimer *timer = new QTimer();
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(move()));
timer->start(50);
//sound bullet
QMediaPlayer *bulletSound = new QMediaPlayer();
bulletSound->setMedia(QUrl("qrc:/sounds/shoot.wav"));
//sound
if (bulletSound->state() == QMediaPlayer::PlayingState)
{
bulletSound->setPosition(0); //rewind
}
else bulletSound->play(); //it should be in QMediaPlayer::StoppedState
}
示例3: mouseMoveEvent
//.........这里部分代码省略.........
fDoc->fCurrentVoice->RepositionPhrase(fSelectedPhrase, fDoc->Duration());
needUpdate = true;
}
}
else if (fDraggingEnd == 1)
{
if (frame != fSelectedPhrase->fEndFrame)
{
fDoc->fDirty = true;
fSelectedPhrase->fEndFrame = frame;
if (fSelectedPhrase->fEndFrame < fSelectedPhrase->fStartFrame + 1)
fSelectedPhrase->fEndFrame = fSelectedPhrase->fStartFrame + 1;
fDoc->fCurrentVoice->RepositionPhrase(fSelectedPhrase, fDoc->Duration());
needUpdate = true;
}
}
else if (fDraggingEnd == 2)
{
if (frame != fOldFrame)
{
fDoc->fDirty = true;
fSelectedPhrase->fStartFrame += frame - fOldFrame;
fSelectedPhrase->fEndFrame += frame - fOldFrame;
if (fSelectedPhrase->fEndFrame < fSelectedPhrase->fStartFrame + 1)
fSelectedPhrase->fEndFrame = fSelectedPhrase->fStartFrame + 1;
fDoc->fCurrentVoice->RepositionPhrase(fSelectedPhrase, fDoc->Duration());
needUpdate = true;
}
}
}
else if (fSelectedWord)
{
if (fDraggingEnd == 0)
{
if (frame != fSelectedWord->fStartFrame)
{
fDoc->fDirty = true;
fSelectedWord->fStartFrame = frame;
if (fSelectedWord->fStartFrame > fSelectedWord->fEndFrame - 1)
fSelectedWord->fStartFrame = fSelectedWord->fEndFrame - 1;
fParentPhrase->RepositionWord(fSelectedWord);
needUpdate = true;
}
}
else if (fDraggingEnd == 1)
{
if (frame != fSelectedWord->fEndFrame)
{
fDoc->fDirty = true;
fSelectedWord->fEndFrame = frame;
if (fSelectedWord->fEndFrame < fSelectedWord->fStartFrame + 1)
fSelectedWord->fEndFrame = fSelectedWord->fStartFrame + 1;
fParentPhrase->RepositionWord(fSelectedWord);
needUpdate = true;
}
}
else if (fDraggingEnd == 2)
{
if (frame != fOldFrame)
{
fDoc->fDirty = true;
fSelectedWord->fStartFrame += frame - fOldFrame;
fSelectedWord->fEndFrame += frame - fOldFrame;
if (fSelectedWord->fEndFrame < fSelectedWord->fStartFrame + 1)
fSelectedWord->fEndFrame = fSelectedWord->fStartFrame + 1;
fParentPhrase->RepositionWord(fSelectedWord);
needUpdate = true;
}
}
}
else if (fSelectedPhoneme)
{
if (fDraggingEnd == 0)
{
if (frame != fSelectedPhoneme->fFrame)
{
fDoc->fDirty = true;
fSelectedPhoneme->fFrame = frame;
fParentWord->RepositionPhoneme(fSelectedPhoneme);
needUpdate = true;
}
}
}
fOldFrame = frame;
QMediaPlayer *audioPlayer = fDoc->GetAudioPlayer();
if (frame != fScrubFrame)
{
fScrubFrame = frame;
fCurFrame = fScrubFrame;
f = ((real)fScrubFrame / (real)fDoc->Fps()) * 1000.0f;
audioPlayer->setPosition(PG_FLOOR(f));
audioPlayer->play();
emit(frameChanged(fScrubFrame));
needUpdate = true;
}
if (needUpdate)
update();
}