开发者

SDL. Current music position

I load my music 开发者_如何学Gotrack using SDL_mixer function:

Mix_Music * SDLCALL Mix_LoadMUS(const char *file);

For synchronization with video I need to know current music position. How can I determine this?


SDL doesn't seem to expose an easy hook for what you want. Once you trigger Mix_PlayMusic you have a hook to be notified when the music is done playing with Mix_HookMusicFinished, but that's about it.

You could use a completely independent clock mechanism for the video, and trust that the timing is going to "just line up" (e.g. if it's a 4 minute song, it will be done playing exactly 4 minutes after you call play). But since I doubt you're developing for a Real-Time OS, the results won't be ideal.

It might be possible for you to install a hook via Mix_SetPostMix. The "effect" you'd install wouldn't actually be for modifying the audio stream, but just keeping tabs on how many samples have been played and do corrections to the video accordingly. (Just thinking out loud here.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜