如何在Android中使用Delphi和API发出哔声? [英] How do I make a beep sound in Android using Delphi and the API?

查看:240
本文介绍了如何在Android中使用Delphi和API发出哔声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查看了Androidapi.JNI.Media.pas之后,我编写了以下过程:

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;

但是我不知道如何为StreamType设置值? 谢谢

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

推荐答案

流类型标识必须在其上发出蜂鸣声的.它是0到4之间的整数:

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)

这篇关于如何在Android中使用Delphi和API发出哔声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆