WIP: Updated volume support.

This commit is contained in:
Pieter Hulshoff 2019-03-24 21:26:24 +01:00
parent c9a87c3d9e
commit 46cc7084d1
6 changed files with 23 additions and 3 deletions

View File

@ -54,6 +54,8 @@ public:
virtual void setText(std::string text, int id = -1) {};
virtual void setImage(std::string filePath, int id = -1) {};
int getId( );
virtual void setVolume(double volume) {};
virtual double getVolume() {return 0.0;};
protected:
Page &page;

View File

@ -83,6 +83,7 @@ void ReloadableMedia::update(float dt)
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
}
static_cast<VideoComponent *>(loadedComponent_)->setVolume(volume_);
loadedComponent_->update(dt);
}
@ -456,3 +457,15 @@ void ReloadableMedia::draw()
loadedComponent_->draw();
}
}
void ReloadableMedia::setVolume(double volume)
{
volume_ = volume;
}
double ReloadableMedia::getVolume()
{
return volume_;
}

View File

@ -36,6 +36,8 @@ public:
Component *findComponent(std::string collection, std::string type, std::string basename, std::string filepath, bool systemMode);
void enableTextFallback_(bool value);
void setVolume(double volume);
double getVolume();
private:
void reloadTexture();
@ -55,4 +57,5 @@ private:
std::string currentCollection_;
Page *page_;
int displayOffset_;
double volume_;
};

View File

@ -51,6 +51,7 @@ void VideoComponent::update(float dt)
}
if(isPlaying_)
{
videoInst_->setVolume(volume_);
videoInst_->update(dt);
// video needs to run a frame to start getting size info

View File

@ -767,9 +767,9 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
static_cast<ReloadableMedia *>(c)->enableTextFallback_(false);
}
xml_attribute<> *volumeXml = componentXml->first_attribute("volume");
if(volumeXml)
static_cast<VideoComponent *>(c)->setVolume(Utils::convertFloat(volumeXml->value()));
xml_attribute<> *volumeXml = componentXml->first_attribute("volume");
if(volumeXml)
static_cast<ReloadableMedia *>(c)->setVolume(Utils::convertFloat(volumeXml->value()));
}
if(c)

View File

@ -31,4 +31,5 @@ public:
virtual void draw() = 0;
virtual int getHeight() = 0;
virtual int getWidth() = 0;
virtual void setVolume(double volume) = 0;
};