I’m totally new to FMod and seem to be stuck with an extremely basic task: Using setPosition to skip the playback head to another part of the sound file.
I’m using the following to play a sound:
[code:e5ibhac6] FMOD::System *mysystem;
result = FMOD::System_Create(&mysystem); result = mysystem->init(100, FMOD_INIT_NORMAL, 0); result = mysystem->createSound(file, FMOD_SOFTWARE, 0, &sound); result = mysystem->playSound(FMOD_CHANNEL_FREE , sound, true, &channel);[/code:e5ibhac6]
The following is executed everytime the playhead is dragged to another location on the timeline.
[code:e5ibhac6] resultSP = channel->setPosition(secs, FMOD_TIMEUNIT_MS);
result = channel->setPaused(false);[/code:e5ibhac6]
The above makes the sound file play to wherever the playhead is positioned initially and this works fine, so I can start the playback from any location. But every subsequent dragging event returns FMOD_ERR_INVALID_HANDLE for resultSP.
I can’t figure out why the code works the very first time and not again. I’m obviously missing something. Any help appreciated.
Edit: Just thought I’d mention that ‘secs’ (in setPosition) is actually a value in milliseconds
- saajjj asked 8 years ago
The invalid handle error is common. It means that the channel handle was invalidated: either channel->stop() was called or that channel was stolen. If this is expected you can just add
[code:52a3i166]if (resultSP == FMOD_ERR_INVALID_HANDLE)
result = mysystem->playSound(FMOD_CHANNEL_FREE , sound, true, &channel);[/code:52a3i166]
- Guest answered 8 years ago
Please login first to submit.