diff --git a/src/Sources/VideoSource.cpp b/src/Sources/VideoSource.cpp index be48db9..3984ed8 100644 --- a/src/Sources/VideoSource.cpp +++ b/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(); } } diff --git a/src/Sources/VideoSource.h b/src/Sources/VideoSource.h index 7deebd5..a530c2d 100644 --- a/src/Sources/VideoSource.h +++ b/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 };