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

1
src/Sources/VideoSource.h

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

Loading…
Cancel
Save