News:

SMF - Just Installed!

Main Menu

Thread blocking Playback

Started by Kotomin_Nikita, June 17, 2016, 05:24:12 PM

Previous topic - Next topic

Kotomin_Nikita

Hello.
Is there a way to play sound with audioEditorAPI.PlaySound() in such way that the current thread will be blocked till the playback is done?
Now I use construction like this

audioEditorAPI.PlaySound();

//Wait until playback finishes
while (audioEditorAPI.GetPlaybackStatus() != enumPlaybackStatus.PLAYBACK_STOPPED)
{
    System.Threading.Thread.Sleep(200);
}

audioEditorAPI.LoadSoundFromMemory(sound, sound.Length);
audioEditorAPI.PlaySound();


I need to play sounds in loop one after the other. What is the best way to accomplish this?
Thank you.

Administrator

Hello,

I don't think that blocking the main thread in that way could have any kind of benefit from an architectural perspective.

Probably the best thing for you could be creating a playlist using a different API named "Audio DJ Studio API for .NET"
http://www.multimediasoft.com/adjstudnetapi/index.html
so you wouldn't have to mind about waiting for the song end and for loading a new song as the whole stuff would be automatically managed by the internal playlist manager; details about playlists management can be found on the tutorial below:
http://www.multimediasoft.com/adjstudnetapi/help/how_to_manage_a_playlist.htm

If you should have any further doubt or if you should have anything to add to your previous post in order to let me better understand your need to block the main thread, please, feel free to ask.

Kind Regards

Severino Delaurenti
MultiMedia Soft