Example #1
0
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
	FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
	bool exists = f && f->is_open();

	String tempFile = get_user_data_dir();
	if (!exists)
		return FAILED;

	if (p_path.begins_with("res://")) {
		if (PackedData::get_singleton()->has_path(p_path)) {
			print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str());
			return ERR_INVALID_PARAMETER;
		} else {
			p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path());
		}
	} else if (p_path.begins_with("user://"))
		p_path = p_path.replace("user:/", get_user_data_dir());

	memdelete(f);

	print("Playing video: %S\n", p_path.c_str());
	if (_play_video(p_path, p_volume, p_audio_track, p_subtitle_track))
		return OK;
	return FAILED;
}
int AudioStreamPlaybackOGGVorbis::_ov_close_func(void *_f) {

	//printf("close %p\n",_f);
	if (!_f)
		return 0;
	FileAccess *fa = (FileAccess *)_f;
	if (fa->is_open())
		fa->close();
	return 0;
}
Example #3
0
static void *godot_open(void *data, const char *p_fname, int mode) {

	if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
		return NULL;
	};

	FileAccess *f = (FileAccess *)data;
	f->open(p_fname, FileAccess::READ);

	return f->is_open() ? data : NULL;
};
Example #4
0
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
	FileAccess* f = FileAccess::open(p_path, FileAccess::READ);
	bool exists = f && f->is_open();
	printf("file exists for %ls, %i, %p\n", p_path.c_str(), (int)exists, f);
	if (f)
		memdelete(f);
	if (!exists)
		return FAILED;
    if ( _play_video(p_path, p_volume, p_audio_track, p_subtitle_track) )
		return OK;
	return FAILED;
}
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;
};