17 #include "layersound.h"
20 #include <QMediaPlayer>
24 #include "soundclip.h"
29 setName(
tr(
"Sound Layer"));
32 LayerSound::~LayerSound()
36 Status LayerSound::loadSoundClipAtFrame(
const QString& sSoundClipName,
42 return Status::FILE_NOT_FOUND;
48 return Status::ERROR_LOAD_SOUND_FILE;
52 clip->setSoundClipName(sSoundClipName);
53 clip->init(strFilePath);
54 clip->setPos(frameNumber);
59 void LayerSound::updateFrameLengths(
int fps)
61 foreachKeyFrame([&fps](
KeyFrame* pKeyFrame)
63 auto soundClip =
dynamic_cast<SoundClip *
>(pKeyFrame);
64 soundClip->updateLength(fps);
72 foreachKeyFrame([&doc, &layerElem](
KeyFrame* pKeyFrame)
89 void LayerSound::loadDomElement(
const QDomElement& element,
QString dataDirPath, ProgressCallback progressStep)
91 this->loadBaseDomElement(element);
102 if (soundElement.
tagName() ==
"sound")
105 const QString sSoundClipName = soundElement.
attribute(
"name",
"My Sound Clip");
113 Status st = loadSoundClipAtFrame(sSoundClipName, sFullPath, position);
135 if (sDestFileLocation != key->fileName())
140 bool ok =
QFile::copy(key->fileName(), sDestFileLocation);
143 key->setFileName(
"");
147 dd <<
QString(
" KeyFrame.pos() = %1").
arg(key->pos());
148 dd <<
QString(
" Key->fileName() = %1").
arg(key->fileName());
149 dd <<
QString(
" FilePath = %1").
arg(sDestFileLocation);
150 dd <<
QString(
"Couldn't save the sound clip");
151 return Status(Status::FAIL, dd);
153 key->setFileName(sDestFileLocation);
165 SoundClip* LayerSound::getSoundClipWhichCovers(
int frameNumber)
167 KeyFrame* key = getKeyFrameWhichCovers(frameNumber);
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const const
QString filePath(const QString &fileName) const const
bool exists() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
bool copy(const QString &newName)
QDomNode nextSibling() const const
QDomElement toElement() const const
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const const
bool isEmpty() const const
bool isNull() const const
QDomNode firstChild() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString tagName() const const
QDomElement createElement(const QString &tagName)