问题
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