openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

ofVideoPlayer and Emscripten

Open Jonathhhan opened this issue 2 years ago • 10 comments

With the current OF branch the videoPlayer examples only work with Emscripten, if I use ofSoundStream (before loading the video player) in ofSetup. Somehow that was not needed before...

Thats the error without ofSoundStream:

Uncaught ReferenceError: AUDIO is not defined
    at _html5video_player_create (videoPlayerExample.js:1:183919)
    at ofxEmscriptenVideoPlayer::ofxEmscriptenVideoPlayer() (videoPlayerExample.wasm:0x4605f)
    at ofApp::setup() (videoPlayerExample.wasm:0x908f4)

AUDIO is defined in https://github.com/openframeworks/openFrameworks/blob/master/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js and used by the videoPlayer, because it uses the same audioContext (which is needed for panning for example)...

Jonathhhan avatar Mar 12 '23 04:03 Jonathhhan

Is this some regression? it used to work well? if yes can you please try to identify which commit introduced this behavior?

dimitre avatar Mar 12 '23 22:03 dimitre

@dimitre yes, it was working before (not long ago). will try to find the commit the next days...

Jonathhhan avatar Mar 13 '23 01:03 Jonathhhan

can you please test it again in latest master?

dimitre avatar Mar 14 '23 11:03 dimitre

@dimitre still the same with the latest master. I will have a look into the recent commits, when I have some time (soon).

Jonathhhan avatar Mar 15 '23 16:03 Jonathhhan

@dimitre I found it (actually not sure how to solve this): https://github.com/openframeworks/openFrameworks/pull/7301/files :)

Jonathhhan avatar Mar 16 '23 00:03 Jonathhhan

@2bbb is there a way to enable soundstream for the videoplayer automatically (like before) with Emscripten? Thank you.

Jonathhhan avatar Mar 18 '23 14:03 Jonathhhan

Hi, @Jonathhhan

maybe there is a way, I think. but I don't understand about Emscripten...

2bbb avatar Mar 19 '23 16:03 2bbb

Notice: I DON'T UNDERSTAND Emscripten.

can we call ofxEmscriptenAudioContext() in ofxEmscriptenVideoPlayer:: load()? (isn't there setup...?) currently ofxEmscriptenAudioContext() is hide in implementation only in ofxEmscriptenSoundPlayer.cpp. but maybe we can test quickly with dirty way to edit ofxEmscriptenVideoPlayer.cpp like:

extern int ofxEmscriptenAudioContext();

bool ofxEmscriptenVideoPlayer::load(string name){
	ofxEmscriptenAudioContext();
	if (name.substr(0, 12) == "blob:http://" || name.substr(0, 13) == "blob:https://"){
  ....
}

this way is to only for test. if it clear problem, then we need to decide to make ofxEmscriptenAudioContext public in header, or not.

2bbb avatar Mar 19 '23 16:03 2bbb

@2bbb thanks a lot. I tried your suggestion but it does not work. No, there is no setup (like in ofVideoPlayer?) Now the error is: Uncaught TypeError: Cannot read properties of undefined (reading 'createMediaElementSource') in: https://github.com/openframeworks/openFrameworks/blob/master/addons/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js

Jonathhhan avatar Mar 21 '23 02:03 Jonathhhan

Sort of a hack but this works for me:

https://gist.github.com/ofTheo/4283463783876f901f80c00f99bc56ec

ofTheo avatar Apr 12 '23 20:04 ofTheo