Skip to content

Commit 7cdd480

Browse files
committed
fixed videoplayer compilation for windows
1 parent 1209606 commit 7cdd480

File tree

3 files changed

+65
-19
lines changed

3 files changed

+65
-19
lines changed

addon_config.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ common:
2626
# or use += in several lines
2727
ADDON_DEPENDENCIES = ofxAssimpModelLoader ofxGui ofxKinect ofxNetwork ofxOpenCv ofxOsc ofxSvg ofxVectorGraphics ofxXmlSettings
2828
ADDON_DEPENDENCIES += ofxAudioAnalyzer ofxAudioFile ofxBTrack ofxChromaKeyShader ofxCv ofxEasing ofxFFmpegRecorder ofxGLEditor
29-
ADDON_DEPENDENCIES += ofxJSON ofxHapPlayer ofxInfiniteCanvas ofxLua ofxMidi ofxMtlMapping2D
29+
ADDON_DEPENDENCIES += ofxJSON ofxInfiniteCanvas ofxLua ofxMidi ofxMtlMapping2D
3030
ADDON_DEPENDENCIES += ofxPDSP ofxTimeline ofxWarp
3131
ADDON_DEPENDENCIES += ofxImGui
3232

@@ -74,11 +74,11 @@ common:
7474

7575

7676
linux64:
77-
ADDON_DEPENDENCIES += ofxPd ofxPdExternals ofxPython ofxNDI
77+
ADDON_DEPENDENCIES += ofxHapPlayer ofxPd ofxPdExternals ofxPython ofxNDI
7878
ADDON_SOURCES_EXCLUDE = src/objects/video/SyphonSender% src/objects/video/SyphonReceiver%
7979

8080
msys2:
8181
ADDON_SOURCES_EXCLUDE = src/objects/scripting/BashScript% src/objects/scripting/PythonScript% src/objects/sound/PDPatch% src/objects/video/VideoSender% src/objects/video/VideoReceiver% src/objects/video/SyphonSender% src/objects/video/SyphonReceiver%
8282

8383
osx:
84-
ADDON_DEPENDENCIES += ofxPd ofxPdExternals ofxPython ofxNDI ofxSyphon
84+
ADDON_DEPENDENCIES += ofxHapPlayer ofxPd ofxPdExternals ofxPython ofxNDI ofxSyphon

src/objects/video/VideoPlayer.cpp

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

5656
this->initInletsState();
5757

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

6064
lastMessage = "";
6165
isNewObject = false;
@@ -152,7 +156,11 @@ void VideoPlayer::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRen
152156
static_cast<ofTexture *>(_outletParams[0])->clear();
153157
}else{
154158
//static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
155-
*static_cast<ofTexture *>(_outletParams[0]) = *video->getTexture();
159+
#ifndef TARGET_WIN32
160+
*static_cast<ofTexture *>(_outletParams[0]) = *video->getTexture();
161+
#else
162+
static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
163+
#endif
156164
}
157165

158166
// listen to message control (_inletParams[0])
@@ -314,6 +322,7 @@ void VideoPlayer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
314322
canvasZoom = _nodeCanvas.GetCanvasScale();
315323

316324
// file dialog
325+
#ifndef TARGET_WIN32
317326
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)){
318327
ofFile file (fileDialog.selected_path);
319328
if (file.exists()){
@@ -322,6 +331,17 @@ void VideoPlayer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
322331
needToLoadVideo = true;
323332
}
324333
}
334+
#else
335+
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".mov,.mp4,.mpg,.mpeg,.avi", "", scaleFactor)){
336+
ofFile file (fileDialog.selected_path);
337+
if (file.exists()){
338+
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
339+
isFileLoaded = false;
340+
needToLoadVideo = true;
341+
}
342+
}
343+
#endif
344+
325345

326346
}
327347

@@ -349,7 +369,12 @@ void VideoPlayer::drawObjectNodeConfig(){
349369
if (ImGui::IsItemHovered()){
350370
ImGui::BeginTooltip();
351371
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
352-
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi. Compatible codec: HAP");
372+
#ifndef TARGET_WIN32
373+
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi | Compatible codec: HAP");
374+
#else
375+
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi");
376+
#endif
377+
353378
ImGui::PopTextWrapPos();
354379
ImGui::EndTooltip();
355380
}
@@ -402,19 +427,35 @@ void VideoPlayer::drawObjectNodeConfig(){
402427
}
403428
}
404429

405-
ImGuiEx::ObjectInfo(
430+
#ifndef TARGET_WIN32
431+
ImGuiEx::ObjectInfo(
406432
"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",
407433
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
408-
409-
// file dialog
410-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file encoded with the HAP codec", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
411-
ofFile file (fileDialog.selected_path);
412-
if (file.exists()){
413-
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
414-
isFileLoaded = false;
415-
needToLoadVideo = true;
434+
// file dialog
435+
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file encoded with the HAP codec", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
436+
ofFile file (fileDialog.selected_path);
437+
if (file.exists()){
438+
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
439+
isFileLoaded = false;
440+
needToLoadVideo = true;
441+
}
416442
}
417-
}
443+
#else
444+
ImGuiEx::ObjectInfo(
445+
"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.",
446+
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
447+
// file dialog
448+
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
449+
ofFile file (fileDialog.selected_path);
450+
if (file.exists()){
451+
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
452+
isFileLoaded = false;
453+
needToLoadVideo = true;
454+
}
455+
}
456+
#endif
457+
458+
418459
}
419460

420461
//--------------------------------------------------------------

src/objects/video/VideoPlayer.h

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

42-
#include "ofxHapPlayer.h"
42+
#ifndef TARGET_WIN32
43+
#include "ofxHapPlayer.h"
44+
#endif
4345

4446
class VideoPlayer : public PatchObject {
4547

@@ -60,8 +62,11 @@ class VideoPlayer : public PatchObject {
6062

6163
void loadVideoFile();
6264

63-
64-
ofxHapPlayer* video;
65+
#ifndef TARGET_WIN32
66+
ofxHapPlayer* video;
67+
#else
68+
ofVideoPlayer* video;
69+
#endif
6570
float posX, posY, drawW, drawH;
6671
bool isNewObject;
6772
bool isFileLoaded;

0 commit comments

Comments
 (0)