18 #include "soundclip.h"
21 #include <QMediaPlayer>
23 #include "soundplayer.h"
25 SoundClip::SoundClip()
31 mOriginalSoundClipName = s2.mOriginalSoundClipName;
34 SoundClip::~SoundClip()
41 mOriginalSoundClipName = a.mOriginalSoundClipName;
57 setFileName(strSoundFile);
61 bool SoundClip::isValid()
const
63 if (fileName().isEmpty())
68 if (mPlayer ==
nullptr)
78 Q_ASSERT( player !=
nullptr );
79 mPlayer.reset(player);
82 void SoundClip::detachPlayer()
87 void SoundClip::play()
95 void SoundClip::playFromPosition(
int frameNumber,
int fps)
97 int framesIntoSound = frameNumber;
100 framesIntoSound = frameNumber - pos();
102 qreal msPerFrame = 1000.0 / fps;
103 qint64 msIntoSound = qRound(framesIntoSound * msPerFrame);
106 mPlayer->setMediaPlayerPosition(msIntoSound);
111 void SoundClip::pause()
119 void SoundClip::stop()
127 int64_t SoundClip::duration()
const
132 void SoundClip::setDuration(
const int64_t& duration)
134 mDuration = duration;
137 void SoundClip::updateLength(
int fps)
139 setLength(qCeil(mDuration * fps / 1000.0));
bool isEmpty() const const