Skip to content

Commit 66e7d57

Browse files
committed
switched from ofxHapPlayer to native OF video player due to some incompatibility issues with of0.11.2
1 parent 939f054 commit 66e7d57

File tree

4 files changed

+20
-81
lines changed

4 files changed

+20
-81
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ In order to build ofxVisualProgramming, you'll need this addons:
7777

7878
#### [ofxJSON](https://github.com/jeffcrouse/ofxJSON)
7979

80-
#### [ofxHapPlayer](https://github.com/d3cod3/ofxHapPlayer)
81-
8280
#### [ofxImGui](https://github.com/d3cod3/ofxImGui)
8381

8482
#### [ofxInfiniteCanvas](https://github.com/d3cod3/ofxInfiniteCanvas)
@@ -122,7 +120,6 @@ git clone https://github.com/arturoc/ofxEasing
122120
git clone https://github.com/d3cod3/ofxFFmpegRecorder
123121
git clone https://github.com/kylemcdonald/ofxFft
124122
git clone https://github.com/jeffcrouse/ofxJSON
125-
git clone --branch=libavformat https://github.com/d3cod3/ofxHapPlayer
126123
git clone https://github.com/d3cod3/ofxImGui
127124
git clone https://github.com/d3cod3/ofxInfiniteCanvas
128125
git clone https://github.com/danomatika/ofxLua
@@ -396,8 +393,6 @@ ofxFFmpegRecorder original addon by [Furkan Üzümcü](https://github.com/Furkan
396393

397394
ofxJSON original addon by [Jeff Crouse](https://github.com/jeffcrouse/)
398395

399-
ofxHapPlayer original addon by [Tom Butterworth](https://github.com/bangnoise)
400-
401396
ofxImGui original addon by [Jason Van Cleave](https://github.com/jvcleave)
402397

403398
ofxInfiniteCanvas original addon by [Roy Macdonald](https://github.com/roymacdonald)

addon_config.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ common:
7373

7474

7575
linux64:
76-
ADDON_DEPENDENCIES += ofxHapPlayer ofxNDI
76+
ADDON_DEPENDENCIES += ofxNDI
7777
ADDON_SOURCES_EXCLUDE = src/objects/video/SyphonSender% src/objects/video/SyphonReceiver%
7878

7979
msys2:
@@ -83,4 +83,4 @@ vs:
8383
ADDON_SOURCES_EXCLUDE = src/objects/scripting/BashScript% src/objects/video/VideoSender% src/objects/video/VideoReceiver% src/objects/video/SyphonSender% src/objects/video/SyphonReceiver%
8484

8585
osx:
86-
ADDON_DEPENDENCIES += ofxHapPlayer ofxNDI ofxSyphon
86+
ADDON_DEPENDENCIES += ofxNDI ofxSyphon

src/objects/video/VideoPlayer.cpp

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ VideoPlayer::VideoPlayer() : PatchObject("video player"){
5555

5656
this->initInletsState();
5757

58-
#ifndef TARGET_WIN32
59-
video = new ofxHapPlayer();
60-
#else
61-
video = new ofVideoPlayer();
62-
#endif
58+
video = new ofVideoPlayer();
6359

6460
lastMessage = "";
6561
isNewObject = false;
@@ -156,12 +152,7 @@ void VideoPlayer::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRen
156152
static_cast<ofTexture *>(_outletParams[0])->allocate(video->getWidth(),video->getHeight(),GL_RGB);
157153
static_cast<ofTexture *>(_outletParams[0])->clear();
158154
}else{
159-
//static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
160-
#ifndef TARGET_WIN32
161-
*static_cast<ofTexture *>(_outletParams[0]) = *video->getTexture();
162-
#else
163-
static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
164-
#endif
155+
static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
165156
}
166157

167158
// listen to message control (_inletParams[0])
@@ -242,17 +233,7 @@ void VideoPlayer::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRen
242233

243234
// draw node texture preview with OF
244235
if(scaledObjW*canvasZoom > 90.0f){
245-
#ifndef TARGET_WIN32
246-
if(video->getShader()){
247-
video->getShader()->begin();
248-
drawNodeOFTexture(*static_cast<ofTexture *>(_outletParams[0]), posX, posY, drawW, drawH, objOriginX, objOriginY, scaledObjW, scaledObjH, canvasZoom, this->scaleFactor);
249-
video->getShader()->end();
250-
}else{
251-
drawNodeOFTexture(*static_cast<ofTexture *>(_outletParams[0]), posX, posY, drawW, drawH, objOriginX, objOriginY, scaledObjW, scaledObjH, canvasZoom, this->scaleFactor);
252-
}
253-
#else
254-
drawNodeOFTexture(*static_cast<ofTexture *>(_outletParams[0]), posX, posY, drawW, drawH, objOriginX, objOriginY, scaledObjW, scaledObjH, canvasZoom, this->scaleFactor);
255-
#endif
236+
drawNodeOFTexture(*static_cast<ofTexture *>(_outletParams[0]), posX, posY, drawW, drawH, objOriginX, objOriginY, scaledObjW, scaledObjH, canvasZoom, this->scaleFactor);
256237
}
257238
}
258239

@@ -327,16 +308,6 @@ void VideoPlayer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
327308
canvasZoom = _nodeCanvas.GetCanvasScale();
328309

329310
// file dialog
330-
#ifndef TARGET_WIN32
331-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file encoded with the HAP codec", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".mov,.mp4,.mpg,.mpeg,.avi", "", scaleFactor)){
332-
ofFile file (fileDialog.selected_path);
333-
if (file.exists()){
334-
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
335-
isFileLoaded = false;
336-
needToLoadVideo = true;
337-
}
338-
}
339-
#else
340311
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".mov,.mp4,.mpg,.mpeg,.avi", "", scaleFactor)){
341312
ofFile file (fileDialog.selected_path);
342313
if (file.exists()){
@@ -345,7 +316,6 @@ void VideoPlayer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
345316
needToLoadVideo = true;
346317
}
347318
}
348-
#endif
349319

350320

351321
}
@@ -374,12 +344,7 @@ void VideoPlayer::drawObjectNodeConfig(){
374344
if (ImGui::IsItemHovered()){
375345
ImGui::BeginTooltip();
376346
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
377-
#ifndef TARGET_WIN32
378-
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi | Compatible codec: HAP");
379-
#else
380-
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi");
381-
#endif
382-
347+
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi");
383348
ImGui::PopTextWrapPos();
384349
ImGui::EndTooltip();
385350
}
@@ -432,33 +397,18 @@ void VideoPlayer::drawObjectNodeConfig(){
432397
}
433398
}
434399

435-
#ifndef TARGET_WIN32
436-
ImGuiEx::ObjectInfo(
437-
"Simple object for playing video files. It use the HAP codec as standard, so you can use only videos encoded with HAP. More info here: https://hap.video/using-hap.html",
438-
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
439-
// file dialog
440-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file encoded with the HAP codec", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
441-
ofFile file (fileDialog.selected_path);
442-
if (file.exists()){
443-
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
444-
isFileLoaded = false;
445-
needToLoadVideo = true;
446-
}
447-
}
448-
#else
449-
ImGuiEx::ObjectInfo(
450-
"Simple object for playing video files. In mac OSX you can upload .mov and .mp4 files; in linux .mp4, .mpeg and .mpg, while in windows .mp4 and .avi can be used.",
451-
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
452-
// file dialog
453-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
454-
ofFile file (fileDialog.selected_path);
455-
if (file.exists()){
456-
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
457-
isFileLoaded = false;
458-
needToLoadVideo = true;
459-
}
400+
ImGuiEx::ObjectInfo(
401+
"Simple object for playing video files. In mac OSX you can upload .mov and .mp4 files; in linux .mp4, .mpeg and .mpg, while in windows .mp4 and .avi can be used.",
402+
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
403+
// file dialog
404+
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
405+
ofFile file (fileDialog.selected_path);
406+
if (file.exists()){
407+
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
408+
isFileLoaded = false;
409+
needToLoadVideo = true;
460410
}
461-
#endif
411+
}
462412

463413

464414
}

src/objects/video/VideoPlayer.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
#include "ImGuiFileBrowser.h"
4040
#include "IconsFontAwesome5.h"
4141

42-
#ifndef TARGET_WIN32
43-
#include "ofxHapPlayer.h"
44-
#endif
45-
4642
class VideoPlayer : public PatchObject {
4743

4844
public:
@@ -62,11 +58,9 @@ class VideoPlayer : public PatchObject {
6258

6359
void loadVideoFile();
6460

65-
#ifndef TARGET_WIN32
66-
ofxHapPlayer* video;
67-
#else
68-
ofVideoPlayer* video;
69-
#endif
61+
62+
ofVideoPlayer* video;
63+
7064
float posX, posY, drawW, drawH;
7165
bool isNewObject;
7266
bool isFileLoaded;

0 commit comments

Comments
 (0)