void VideoStreamTheoraplayer::set_file(const String& p_file) { if (!audio_factory) { audio_factory = memnew(TPAudioGodotFactory); }; mgr = memnew(TheoraVideoManager); mgr->setAudioInterfaceFactory(audio_factory); if (p_file.find(".mp4") != -1) { std::string file = p_file.replace("res://", "").utf8().get_data(); clip = mgr->createVideoClip(file); } else { TheoraDataSource* ds = memnew(TPDataFA(p_file)); try { clip = mgr->createVideoClip(ds); } catch (_TheoraGenericException e) { printf("exception ocurred! %s\n", e.repr().c_str()); clip = NULL; }; }; clip->pause(); started = true; };
void VideoStreamTheoraplayer::set_file(const String& p_file) { FileAccess* f = FileAccess::open(p_file, FileAccess::READ); if (!f || !f->is_open()) return; if (!audio_factory) { audio_factory = memnew(TPAudioGodotFactory); }; if (mgr == NULL) { mgr = memnew(TheoraVideoManager(4)); mgr->setAudioInterfaceFactory(audio_factory); }; int track = GLOBAL_DEF("theora/audio_track", 0); // hack if (p_file.find(".mp4") != -1) { std::string file = p_file.replace("res://", "").utf8().get_data(); clip = mgr->createVideoClip(file, TH_RGBX, 2, false, track); //clip->set_audio_track(audio_track); memdelete(f); } else { TheoraDataSource* ds = memnew(TPDataFA(f, p_file)); try { clip = mgr->createVideoClip(ds); clip->set_audio_track(audio_track); } catch (_TheoraGenericException e) { printf("exception ocurred! %s\n", e.repr().c_str()); clip = NULL; }; }; clip->pause(); started = true; };