MCI Audio Player Component — sgcAI | eSeGeCe

Audio Player (MCI)

TsgcAudioPlayerMCI plays an audio file through the Windows MCI API. It listens for the real end-of-playback notification rather than guessing from a duration, which is what lets the voice components resume listening at exactly the right moment.

TsgcAudioPlayerMCI

Audio playback for the cloud speech components. Assign it to a Google or Amazon text-to-speech component and the synthesised audio plays as soon as it arrives.

Component class

TsgcAudioPlayerMCI

Purpose

Audio playback

Platforms

Win32 and Win64

sgcAI is self-contained. This component ships inside sgcAI together with the sgcWebSockets Core runtime it is built on, so there is no base license to buy.

Play a file, know when it ended

One method and two events. Usually you assign it to a speech component and never call it directly.

uses
  sgcAI, sgcAI_AudioPlayer_MCI;

var
  oPlayer: TsgcAudioPlayerMCI;
begin
  oPlayer := TsgcAudioPlayerMCI.Create(nil);
  oPlayer.Play('speech.mp3');

  // Normally it is the output of a cloud speech component:
  sgcTextToSpeechGoogle1.AudioPlayer := oPlayer;
  sgcTextToSpeechAmazon1.AudioPlayer := oPlayer;
end;
// includes: sgcAI.hpp, sgcAI_AudioPlayer_MCI.hpp

TsgcAudioPlayerMCI *oPlayer = new TsgcAudioPlayerMCI(NULL);
oPlayer->Play("speech.mp3");

sgcTextToSpeechGoogle1->AudioPlayer = oPlayer;
sgcTextToSpeechAmazon1->AudioPlayer = oPlayer;

Key properties & methods

The members you reach for most often.

Play

Play(aFileName) starts playback of any format the installed MCI drivers understand, which covers WAV and MP3 on a standard Windows installation.

End of playback

The component allocates a hidden window and waits for the MCI notification, so the stop event fires when the audio genuinely finished, not after an estimated duration.

Lifecycle

OnStart and OnStop bracket playback. The voice components hook OnStop to restart microphone capture, which is what makes a hands-free conversation flow.

Wiring

Assign it to AudioPlayer on TsgcTextToSpeechGoogle or TsgcTextToSpeechAmazon. The system speech component needs no player, it speaks directly.

Standalone use

It is a general purpose player, so it is also useful for notification sounds or for replaying a recording captured by one of the recorder components.

Version

Version reports the component version at design time, the same read-only property every sgc component publishes.

Keep exploring

Online HelpFull API reference and usage guide for the sgcAI components.
All sgcAI ComponentsBrowse the full feature matrix of all 15 components.
Download Free TrialPlay synthesised speech and know exactly when it ended.
PricingSingle, Team and Site licenses, full source code, no base product required.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Get Started?

Download the free trial and complete the voice loop in your application.