mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-28 09:38:52 +01:00
WIP: Volume support.
This commit is contained in:
parent
68902745e0
commit
6a4532b0b3
@ -137,3 +137,15 @@ bool Video::isPlaying( )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Video::setVolume(double volume)
|
||||
{
|
||||
volume_ = volume;
|
||||
}
|
||||
|
||||
|
||||
double Video::getVolume()
|
||||
{
|
||||
return volume_;
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ public:
|
||||
void allocateGraphicsMemory( );
|
||||
void draw( );
|
||||
virtual bool isPlaying( );
|
||||
void setVolume(double volume);
|
||||
double getVolume();
|
||||
|
||||
protected:
|
||||
Component *video_;
|
||||
@ -41,5 +43,6 @@ protected:
|
||||
|
||||
private:
|
||||
static bool enabled_;
|
||||
double volume_;
|
||||
|
||||
};
|
||||
|
||||
@ -28,6 +28,7 @@ VideoComponent::VideoComponent(IVideo *videoInst, Page &p, std::string videoFile
|
||||
, scaleX_(scaleX)
|
||||
, scaleY_(scaleY)
|
||||
, isPlaying_(false)
|
||||
, volume_(1.0)
|
||||
{
|
||||
// AllocateGraphicsMemory();
|
||||
}
|
||||
@ -105,3 +106,15 @@ bool VideoComponent::isPlaying()
|
||||
{
|
||||
return isPlaying_;
|
||||
}
|
||||
|
||||
|
||||
void VideoComponent::setVolume(double volume)
|
||||
{
|
||||
volume_ = volume;
|
||||
}
|
||||
|
||||
|
||||
double VideoComponent::getVolume()
|
||||
{
|
||||
return volume_;
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ public:
|
||||
void freeGraphicsMemory();
|
||||
void allocateGraphicsMemory();
|
||||
virtual bool isPlaying();
|
||||
void setVolume(double volume);
|
||||
double getVolume();
|
||||
|
||||
private:
|
||||
std::string videoFile_;
|
||||
@ -40,4 +42,5 @@ private:
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
bool isPlaying_;
|
||||
double volume_;
|
||||
};
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "Component/ReloadableScrollingText.h"
|
||||
#include "Component/ScrollingList.h"
|
||||
#include "Component/Video.h"
|
||||
#include "Component/VideoComponent.h"
|
||||
#include "Animate/AnimationEvents.h"
|
||||
#include "Animate/TweenTypes.h"
|
||||
#include "../Sound/Sound.h"
|
||||
@ -431,6 +432,7 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
|
||||
xml_attribute<> *srcXml = componentXml->first_attribute("src");
|
||||
xml_attribute<> *numLoopsXml = componentXml->first_attribute("numLoops");
|
||||
xml_attribute<> *idXml = componentXml->first_attribute("id");
|
||||
xml_attribute<> *volumeXml = componentXml->first_attribute("volume");
|
||||
|
||||
int id = -1;
|
||||
if (idXml)
|
||||
@ -463,6 +465,8 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
|
||||
}
|
||||
buildViewInfo(componentXml, c->baseViewInfo);
|
||||
loadTweens(c, componentXml);
|
||||
if(volumeXml)
|
||||
c->setVolume(Utils::convertFloat(volumeXml->value()));
|
||||
page->addComponent(c);
|
||||
}
|
||||
}
|
||||
@ -762,6 +766,10 @@ 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()));
|
||||
}
|
||||
|
||||
if(c)
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
std::string retrofe_version_major = "0";
|
||||
std::string retrofe_version_minor = "8";
|
||||
std::string retrofe_version_build = "22";
|
||||
std::string retrofe_version_build = "23";
|
||||
|
||||
|
||||
std::string Version::getString( )
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include <gst/app/gstappsink.h>
|
||||
#include <gst/video/gstvideometa.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
bool GStreamerVideo::initialized_ = false;
|
||||
|
||||
@ -56,6 +57,7 @@ GStreamerVideo::GStreamerVideo()
|
||||
, isPlaying_(false)
|
||||
, playCount_(0)
|
||||
, numLoops_(0)
|
||||
, volume_(1.0)
|
||||
{
|
||||
}
|
||||
GStreamerVideo::~GStreamerVideo()
|
||||
@ -348,6 +350,17 @@ void GStreamerVideo::update(float /* dt */)
|
||||
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
|
||||
if(playbin_)
|
||||
{
|
||||
if(volume_ > 1.0)
|
||||
volume_ = 1.0;
|
||||
gst_stream_volume_set_volume( GST_STREAM_VOLUME( playbin_ ), GST_STREAM_VOLUME_FORMAT_LINEAR, static_cast<double>(volume_));
|
||||
if(volume_ < 0.1)
|
||||
gst_stream_volume_set_mute( GST_STREAM_VOLUME( playbin_ ), true );
|
||||
else
|
||||
gst_stream_volume_set_mute( GST_STREAM_VOLUME( playbin_ ), false );
|
||||
}
|
||||
|
||||
if(videoBuffer_)
|
||||
{
|
||||
GstVideoMeta *meta;
|
||||
@ -450,3 +463,9 @@ bool GStreamerVideo::isPlaying()
|
||||
{
|
||||
return isPlaying_;
|
||||
}
|
||||
|
||||
|
||||
void GStreamerVideo::setVolume(double volume)
|
||||
{
|
||||
volume_ = volume;
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ public:
|
||||
int getHeight();
|
||||
int getWidth();
|
||||
bool isPlaying();
|
||||
void setVolume(double volume);
|
||||
|
||||
private:
|
||||
static void processNewBuffer (GstElement *fakesink, GstBuffer *buf, GstPad *pad, gpointer data);
|
||||
@ -62,4 +63,5 @@ private:
|
||||
int playCount_;
|
||||
std::string currentFile_;
|
||||
int numLoops_;
|
||||
double volume_;
|
||||
};
|
||||
|
||||
@ -22,6 +22,7 @@ bool VideoFactory::enabled_ = true;
|
||||
int VideoFactory::numLoops_ = 0;
|
||||
IVideo *VideoFactory::instance_ = NULL;
|
||||
|
||||
|
||||
IVideo *VideoFactory::createVideo()
|
||||
{
|
||||
|
||||
@ -35,12 +36,20 @@ IVideo *VideoFactory::createVideo()
|
||||
return instance_;
|
||||
}
|
||||
|
||||
|
||||
void VideoFactory::setEnabled(bool enabled)
|
||||
{
|
||||
enabled_ = enabled;
|
||||
}
|
||||
|
||||
|
||||
void VideoFactory::setNumLoops(int numLoops)
|
||||
{
|
||||
numLoops_ = numLoops;
|
||||
}
|
||||
|
||||
|
||||
void VideoFactory::setVolume(double volume)
|
||||
{
|
||||
((GStreamerVideo *)(instance_))->setVolume(volume);
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ public:
|
||||
static IVideo *createVideo();
|
||||
static void setEnabled(bool enabled);
|
||||
static void setNumLoops(int numLoops);
|
||||
static void setVolume(double volume);
|
||||
|
||||
private:
|
||||
static bool enabled_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user