# Html5 接入Fmod 2.02版本播放MP3文件失败。

**URL:** <https://qa.fmod.com/t/html5-fmod-2-02-mp3/22748>\
**Category:** 中文支持\
**Created:** [March 31, 2025, 3:04am UTC](https://qa.fmod.com/t/html5-fmod-2-02-mp3/22748 "2025-03-31T03:04:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shanling4822](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@shanling4822](https://qa.fmod.com/u/shanling4822)\
**Post date:** [March 31, 2025, 3:04am UTC](https://qa.fmod.com/t/html5-fmod-2-02-mp3/22748/1 "2025-03-31T03:04:40Z")

</div>

我使用wasm的c++开发接入2.02版本接入w32 lib，播放音频文件报没有支持回调函数。  
audio\_sound\_sptr fmod\_service::do\_create\_sound(  
const char\* path, uint32\_t flag, int32\_t group\_id) {  
FMOD::ChannelGroup\* group = get\_sound\_group(group\_id);  
if (group == nullptr) {  
return nullptr;  
}

```
FMOD::Sound* fmod_snd = nullptr;
raw_sound_sptr raw_snd = nullptr;
fmod_sound_vec* data = nullptr;

char path_ex[MAX_PATH_LEN + 16];
::sprintf(path_ex, "%s<%d>", path, flag);

raw_snd = _sound_cache->get(path_ex);
if (raw_snd) {
	if (!(flag & sound_flag::SYNC_LOAD)) {
		fmod_snd = raw_snd->_snd;
		fmod_snd->getUserData(&(void*&)data);
	}
} else {
	FMOD_MODE mode = FMOD_LOOP_NORMAL;
	mode |= (flag & sound_flag::IS_3D) ? FMOD_3D | FMOD_3D_LINEARROLLOFF : FMOD_2D;
	mode |= (flag & sound_flag::STREAM) ? FMOD_CREATESTREAM : FMOD_CREATESAMPLE;
	FMOD_CREATESOUNDEXINFO* exi_ptr = nullptr;
	FMOD_CREATESOUNDEXINFO exinfo;

	if (!(flag & sound_flag::SYNC_LOAD)) {
		static int thread_id = 0;
		if (thread_id > 4) {
			thread_id = 0;
		}
		data = new fmod_sound_vec();
		memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
		exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
		exinfo.nonblockcallback = load_callback;
		exinfo.nonblockthreadid = thread_id++;
		exinfo.userdata = (void*)data; // 异步加载中不能使用setUserData，只能由此处传递

		exi_ptr = &exinfo;
		mode |= FMOD_NONBLOCKING;
	}

	FMOD_RESULT result = _system->createSound(path, mode, exi_ptr, &fmod_snd);
	if (FMOD_CHECK_ERROR(result) || !fmod_snd) {
		if (data) {
			delete data;
		}
		LOGE("FMOD", "Failed to load sound: %s!", path);
		return nullptr;
	}
	bool stream = (flag & sound_flag::STREAM) != 0;
	raw_snd = rx_make_shared<raw_sound>(fmod_snd, stream);
	_sound_cache->set(path_ex, raw_snd);

	if (!(mode & FMOD_NONBLOCKING)) {
		on_fmod_loaded(fmod_snd, stream, path);
	}
}

fmod_sound_sptr sound = rx_make_shared<fmod_sound>(path, raw_snd, group, flag);
if (data != nullptr) {
	sound->_loading = true;
	data->push_back(sound);
}
return sound;

```

}  
文件系统也设置过  
result = \_system-\>setFileSystem(open\_callback, close\_callback,  
read\_callback, seek\_callback, nullptr, nullptr, -1);  
if (FMOD\_CHECK\_ERROR(result)) {  
break;  
}  
但是通过日志看没有进入open\_callback回调函数。  
请问是哪里使用错误吗？播放event接口是有效的。

---

<div class="post-metadata">

**Author:** ![li\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/li_fmod/32/6577_2.png) [@li\_fmod](https://qa.fmod.com/u/li_fmod)\
**Post date:** [April 4, 2025, 5:34am UTC](https://qa.fmod.com/t/html5-fmod-2-02-mp3/22748/2 "2025-04-04T05:34:29Z")

</div>

你好，

非常感谢你分享的代码和信息。

> [@shanling4822](#):
>
> 我使用wasm的c++开发接入2.02版本接入w32 lib，播放音频文件报没有支持回调函数。

可以麻烦你分享一下具体的报错信息吗？

> [@shanling4822](#):
>
> 但是通过日志看没有进入open\_callback回调函数。  
> 请问是哪里使用错误吗？播放event接口是有效的。

如果在使用 [System::setFileSystem](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_setfilesystem) 后，[open\_callback](https://www.fmod.com/docs/2.02/api/core-api-system.html#fmod_file_open_callback) 还是没有调用的话，听起来像是由于文件路径不正确或文件未成功加载，导致传递给 [System::createSound](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_createsound) 的路径无效或无法访问。

不知是否能麻烦你分享一下日志让我们进行调查呢？
