18 #include "soundclip.h" 
   21 #include <QMediaPlayer> 
   22 #include "soundplayer.h" 
   24 SoundClip::SoundClip()
 
   29 SoundClip::~SoundClip()
 
   34 Status SoundClip::init( 
const QString& strSoundFile )
 
   36     if ( !fileName().isEmpty() )
 
   40     setFileName( strSoundFile );
 
   44 bool SoundClip::isValid()
 
   46     if ( fileName().isEmpty() )
 
   51     if ( mPlayer == 
nullptr )
 
   61     Q_ASSERT( player != 
nullptr );
 
   62     mPlayer.reset( player );
 
   65 void SoundClip::detachPlayer()
 
   70 void SoundClip::play()
 
   78 void SoundClip::playFromPosition(
int frameNumber, 
int fps)
 
   80     int framesIntoSound = frameNumber - pos();
 
   81     int msPerFrame = 1000 / fps;
 
   82     int msIntoSound = framesIntoSound * msPerFrame;
 
   86         mPlayer->setMediaPlayerPosition(msIntoSound);
 
   91 void SoundClip::stop()
 
   99 int64_t SoundClip::duration()
 const 
  104 void SoundClip::setDuration(
const int64_t &duration)
 
  106     mDuration = duration;
 
  109 void SoundClip::updateLength(
int fps)
 
  111     setLength(mDuration * fps / 1000.0);