Browse Source

Fix `VideoSource` audio off when `enableAudio` flag is false

master
Krisjanis Rijnieks 9 years ago
parent
commit
7fd227e5a4
  1. 9
      src/Sources/VideoSource.cpp
  2. 1
      src/Sources/VideoSource.h

9
src/Sources/VideoSource.cpp

@ -13,6 +13,7 @@ VideoSource::VideoSource(){
omxPlayer = 0; omxPlayer = 0;
#else #else
videoPlayer = 0; videoPlayer = 0;
_initialVolumeSet = false;
#endif #endif
} }
@ -35,8 +36,8 @@ void VideoSource::loadVideo(string & filePath){
videoPlayer = new ofVideoPlayer(); videoPlayer = new ofVideoPlayer();
videoPlayer->load(filePath); videoPlayer->load(filePath);
videoPlayer->setLoopState(OF_LOOP_NORMAL); videoPlayer->setLoopState(OF_LOOP_NORMAL);
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f);
videoPlayer->play(); videoPlayer->play();
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f);
texture = &(videoPlayer->getTexture()); texture = &(videoPlayer->getTexture());
ofAddListener(ofEvents().update, this, &VideoSource::update); ofAddListener(ofEvents().update, this, &VideoSource::update);
#endif #endif
@ -62,6 +63,12 @@ void VideoSource::clear(){
#ifndef TARGET_RASPBERRY_PI #ifndef TARGET_RASPBERRY_PI
void VideoSource::update(ofEventArgs & args){ void VideoSource::update(ofEventArgs & args){
if(videoPlayer != 0){ if(videoPlayer != 0){
if(!_initialVolumeSet){
if(videoPlayer->isInitialized()){
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f);
_initialVolumeSet = true;
}
}
videoPlayer->update(); videoPlayer->update();
} }
} }

1
src/Sources/VideoSource.h

@ -37,6 +37,7 @@ class VideoSource : public BaseSource {
// Go with ofVideoPlayer or // Go with ofVideoPlayer or
// TODO: High Performance Video player on newer Macs // TODO: High Performance Video player on newer Macs
ofVideoPlayer * videoPlayer; ofVideoPlayer * videoPlayer;
bool _initialVolumeSet;
#endif #endif
}; };

Loading…
Cancel
Save