如何使用Delphi和API在Android中发出哔声?

时间:2015-06-19 13:05:41

标签: android firemonkey delphi-xe7

看了Androidapi.JNI.Media.pas后,我编写了以下程序:

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;

但我无法弄清楚如何为StreamType设置值? 感谢

1 个答案:

答案 0 :(得分:4)

流类型标识必须播放蜂鸣声的。它是0到4之间的整数:

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