How do I make a beep sound in Android using Delphi and the API?

这一生的挚爱 提交于 2019-12-12 04:06:18

问题


After having a look at the Androidapi.JNI.Media.pas, I coded the following procedure:

uses
  Androidapi.JNIBridge,
  AndroidApi.JNI.Media;

procedure Sound(ADuration: Integer);

implementation

procedure Sound(ADuration: Integer);
var
  Volume: Integer;
  StreamType: Integer;
  ToneType: Integer;
  ToneGenerator: JToneGenerator;
begin

  Volume := TJToneGenerator.JavaClass.MAX_VOLUME;

  StreamType := ?
  ToneType := TJToneGenerator.JavaClass.TONE_DTMF_0;

  ToneGenerator := TJToneGenerator.JavaClass.init(StreamType, Volume);
  ToneGenerator.startTone(ToneType, ADuration);

end;

but I can't figure out how to set a value for the StreamType? Thanks


回答1:


The stream type identify the stream on which the beep must be played. It is an integer between 0 and 4 :

  • STREAM_VOICE_CALL (0)
  • STREAM_SYSTEM (1)
  • STREAM_RING (2)
  • STREAM_MUSIC(3)
  • STREAM_ALARM(4)


来源:https://stackoverflow.com/questions/30938946/how-do-i-make-a-beep-sound-in-android-using-delphi-and-the-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!