diff --git a/RetroFE/Source/Graphics/Component/Video.cpp b/RetroFE/Source/Graphics/Component/Video.cpp index 7cbee4d..f5d94d3 100644 --- a/RetroFE/Source/Graphics/Component/Video.cpp +++ b/RetroFE/Source/Graphics/Component/Video.cpp @@ -137,3 +137,15 @@ bool Video::isPlaying( ) return false; } } + + +void Video::setVolume(double volume) +{ + volume_ = volume; +} + + +double Video::getVolume() +{ + return volume_; +} diff --git a/RetroFE/Source/Graphics/Component/Video.h b/RetroFE/Source/Graphics/Component/Video.h index ff81822..c6404aa 100644 --- a/RetroFE/Source/Graphics/Component/Video.h +++ b/RetroFE/Source/Graphics/Component/Video.h @@ -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_; }; diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.cpp b/RetroFE/Source/Graphics/Component/VideoComponent.cpp index da80846..00f4a9e 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.cpp +++ b/RetroFE/Source/Graphics/Component/VideoComponent.cpp @@ -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_; +} diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.h b/RetroFE/Source/Graphics/Component/VideoComponent.h index 7b486fb..3fc9714 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.h +++ b/RetroFE/Source/Graphics/Component/VideoComponent.h @@ -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_; }; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index c36d559..de30de2 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -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(c)->enableTextFallback_(false); } + + xml_attribute<> *volumeXml = componentXml->first_attribute("volume"); + if(volumeXml) + static_cast(c)->setVolume(Utils::convertFloat(volumeXml->value())); } if(c) diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 1d2c651..912e46e 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -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( ) diff --git a/RetroFE/Source/Video/GStreamerVideo.cpp b/RetroFE/Source/Video/GStreamerVideo.cpp index eb39d61..dcf4d00 100644 --- a/RetroFE/Source/Video/GStreamerVideo.cpp +++ b/RetroFE/Source/Video/GStreamerVideo.cpp @@ -30,6 +30,7 @@ #include #include #include +#include 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(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; +} diff --git a/RetroFE/Source/Video/GStreamerVideo.h b/RetroFE/Source/Video/GStreamerVideo.h index 3ac4579..7817829 100644 --- a/RetroFE/Source/Video/GStreamerVideo.h +++ b/RetroFE/Source/Video/GStreamerVideo.h @@ -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_; }; diff --git a/RetroFE/Source/Video/VideoFactory.cpp b/RetroFE/Source/Video/VideoFactory.cpp index 7a91114..8ba1965 100644 --- a/RetroFE/Source/Video/VideoFactory.cpp +++ b/RetroFE/Source/Video/VideoFactory.cpp @@ -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); +} diff --git a/RetroFE/Source/Video/VideoFactory.h b/RetroFE/Source/Video/VideoFactory.h index f5acee6..a6c0924 100644 --- a/RetroFE/Source/Video/VideoFactory.h +++ b/RetroFE/Source/Video/VideoFactory.h @@ -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_;