18#include "soundmanager.h"
24#include "layersound.h"
26#include "soundplayer.h"
27#include "layermanager.h"
33SoundManager::~SoundManager()
37bool SoundManager::init()
44 int count = obj->getLayerCount();
45 for (
int i = 0; i < count; ++i)
47 Layer* layer = obj->getLayer(i);
48 if (layer->type() != Layer::SOUND)
55 soundLayer->foreachKeyFrame([
this](
KeyFrame* key)
60 createMediaPlayer(clip);
77 return Status::FILE_NOT_FOUND;
85 QString strCopyFile = editor()->object()->copyFileToDataFolder(strSoundFile);
86 Q_ASSERT(!strCopyFile.
isEmpty());
88 soundClip->init(strCopyFile);
89 if (soundClip->soundClipName().
isEmpty())
91 soundClip->setSoundClipName(
QFileInfo(strSoundFile).fileName());
94 Status st = createMediaPlayer(soundClip);
112 return Status::FILE_NOT_FOUND;
114 soundClip->init(soundClip->fileName());
116 Status st = createMediaPlayer(soundClip);
124int SoundManager::soundClipCount()
const
130 for (
int i = 0; i < layerManager->count(); ++i)
132 Layer* layer = layerManager->getLayer(i);
133 if (layer->type() != Layer::SOUND)
138 totalCount += layer->keyFrameCount();
143void SoundManager::onDurationChanged(
SoundPlayer* player, int64_t duration)
147 double fps =
static_cast<double>(editor()->fps());
149 double frameLength = duration * fps / 1000.0;
150 clip->setLength(
static_cast<int>(frameLength));
151 clip->setDuration(duration);
155 emit soundClipDurationChanged();
161 newPlayer->init(clip);
163 connect(newPlayer, &SoundPlayer::durationChanged,
this, &SoundManager::onDurationChanged);
void notifyAnimationLengthChanged()
This should be emitted whenever the animation length frames, eg.
bool exists() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool isEmpty() const const