I’ve been racking my brain trying to figure out how to be informed when a stream has finished playing. I could use polling, but this is slow and lazy. Is there a way to set a callback for when the stream has completed?
I am creating a media player and I need to know when the current stream has finished so I can playSound() the next one. What happened to SetEndCallback() from 3.75?
- AngryLlama asked 11 years ago
The reason it is in System::update is to keep it single threaded and avoid some of the horrible race condition problems you can get, it keeps everything in sync better. It may change in the future but it is a lot more solid this way.
This function requires that I call System::update() in order to execute the callback. So this is essentially the same as polling isPlaying(). This is bad, because I will have to call this around 50Hz in order to change songs as soon as possible
[quote="FireStorm":10kolzbx]do you really think you need to do that as frequently for a media player?
anyway, if you don’t want to call update, get the length of your song so you’ll know approximately when it’ll finish[/quote:10kolzbx]
I really want it to be as seamless as possible. I hate having a brief pause between songs, especially when they are supposed to be connected. For example: an intro then a song.
I can’t predict when the song will end because the user may pause, rewind, of fast forward the track. But I’ll try sticking an update() in the event loop and see if that gives me a fast enough response.
If you want gapless playback you should be looking at stream stitching not trying to join 2 streams together. For example in FMOD an audio CD is loaded as a stream with a number of substreams (Sound::getSubSound) which are as many as there are tracks on the CD. When you play the subsound, you just get that track being played. If you play the parent sound, you get all tracks played in a row with absolutely no gap. You can take any 2 streams, put them in a parent sound, then play the parent to get a seamless sentence.
See the realtimestitching example. That is a bit more complicated than what you need, but it shows the same principal.
I would like that callbacks was like were in the version 3.x of Fmod, without having to call to System:Update. The reason to use callback is not to have to worry to do poll of certain functions. My system works well without System:Update and to have to add loop for update does not seem to me good idea. I prefer to do poll in loop 😥
It seems that System: Update == Poll
Sorry for my english.
- LeoCombes answered 11 years ago
Please login first to submit.