Skip to content

Commit 9fd5db1

Browse files
committed
added ofxHapPlayer as default Mosaic codec for video player object
1 parent bd3ecdc commit 9fd5db1

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ 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+
8082
#### [ofxImGui](https://github.com/d3cod3/ofxImGui)
8183

8284
#### [ofxInfiniteCanvas](https://github.com/d3cod3/ofxInfiniteCanvas)
@@ -125,6 +127,7 @@ git clone https://github.com/arturoc/ofxEasing
125127
git clone https://github.com/d3cod3/ofxFFmpegRecorder
126128
git clone https://github.com/Akira-Hayasaka/ofxGLEditor
127129
git clone https://github.com/jeffcrouse/ofxJSON
130+
git clone https://github.com/d3cod3/ofxHapPlayer
128131
git clone https://github.com/d3cod3/ofxImGui
129132
git clone https://github.com/d3cod3/ofxInfiniteCanvas
130133
git clone --branch=of-0.10.0 https://github.com/d3cod3/ofxLua
@@ -402,6 +405,8 @@ ofxGLEditor original addon by [Akira Hayasaka](https://github.com/Akira-Hayasaka
402405

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

408+
ofxHapPlayer original addon by [Tom Butterworth](https://github.com/bangnoise)
409+
405410
ofxImGui original addon by [Jason Van Cleave](https://github.com/jvcleave)
406411

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

addon_config.mk

Lines changed: 1 addition & 1 deletion
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 ofxInfiniteCanvas ofxLua ofxMidi ofxMtlMapping2D
29+
ADDON_DEPENDENCIES += ofxJSON ofxHapPlayer ofxInfiniteCanvas ofxLua ofxMidi ofxMtlMapping2D
3030
ADDON_DEPENDENCIES += ofxPDSP ofxTimeline ofxWarp
3131
ADDON_DEPENDENCIES += ofxImGui
3232

src/objects/video/VideoPlayer.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ VideoPlayer::VideoPlayer() : PatchObject("video player"){
5757

5858
this->initInletsState();
5959

60-
video = new ofVideoPlayer();
60+
video = new ofxHapPlayer();
6161

6262
lastMessage = "";
6363
isNewObject = false;
@@ -155,7 +155,8 @@ void VideoPlayer::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRen
155155
static_cast<ofTexture *>(_outletParams[0])->allocate(video->getWidth(),video->getHeight(),GL_RGB);
156156
static_cast<ofTexture *>(_outletParams[0])->clear();
157157
}else{
158-
static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
158+
//static_cast<ofTexture *>(_outletParams[0])->loadData(video->getPixels());
159+
*static_cast<ofTexture *>(_outletParams[0]) = *video->getTexture();
159160
}
160161

161162
// listen to message control (_inletParams[0])
@@ -217,6 +218,8 @@ void VideoPlayer::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRen
217218
if(video->isPlaying()){ // play
218219
video->update();
219220

221+
//ofLog(OF_LOG_NOTICE,"%s: duration = %f",this->getName().c_str(),video->getDuration());
222+
220223
// preload first video frame into outlet texture
221224
if(preloadFirstFrame && video->getCurrentFrame() > 0){
222225
preloadFirstFrame = false;
@@ -315,7 +318,7 @@ void VideoPlayer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
315318
canvasZoom = _nodeCanvas.GetCanvasScale();
316319

317320
// file dialog
318-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".mov,.mp4,.mpg,.mpeg,.avi", "", scaleFactor)){
321+
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)){
319322
ofFile file (fileDialog.selected_path);
320323
if (file.exists()){
321324
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());
@@ -350,7 +353,7 @@ void VideoPlayer::drawObjectNodeConfig(){
350353
if (ImGui::IsItemHovered()){
351354
ImGui::BeginTooltip();
352355
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
353-
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg");
356+
ImGui::TextUnformatted("Open a video file. Compatible extensions: .mov .mp4 .mpg .mpeg .avi. Compatible codec: HAP");
354357
ImGui::PopTextWrapPos();
355358
ImGui::EndTooltip();
356359
}
@@ -408,11 +411,11 @@ void VideoPlayer::drawObjectNodeConfig(){
408411
}
409412

410413
ImGuiEx::ObjectInfo(
411-
"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.",
414+
"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",
412415
"https://mosaic.d3cod3.org/reference.php?r=video-player", scaleFactor);
413416

414417
// file dialog
415-
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".mov,.mp4,.mpg,.mpeg,.avi", "", scaleFactor)){
418+
if(ImGuiEx::getFileDialog(fileDialog, loadVideoFlag, "Select a video file encoded with the HAP codec", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", "", scaleFactor)){
416419
ofFile file (fileDialog.selected_path);
417420
if (file.exists()){
418421
filepath = copyFileToPatchFolder(this->patchFolderPath,file.getAbsolutePath());

src/objects/video/VideoPlayer.h

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

42+
#include "ofxHapPlayer.h"
43+
4244
class VideoPlayer : public PatchObject {
4345

4446
public:
@@ -59,7 +61,7 @@ class VideoPlayer : public PatchObject {
5961
void loadVideoFile();
6062

6163

62-
ofVideoPlayer* video;
64+
ofxHapPlayer* video;
6365
float posX, posY, drawW, drawH;
6466
bool isNewObject;
6567
bool isFileLoaded;

0 commit comments

Comments
 (0)