| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4343 人关注过本帖
标题:delphi xe7 android 程序出错
只看楼主 加入收藏
lxcndz
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-7-1
收藏
 问题点数:0 回复次数:0 
delphi xe7 android 程序出错
unit Unit3;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
  FMX.ListBox, FMX.Controls.Presentation, FMX.Edit, FMX.StdCtrls, FMX.Ani,
  FMX.Objects, FMX.DateTimeCtrls, FMX.Media,
  Androidapi.JNI.App,Androidapi.JNIBridge,Androidapi.JNI.Os,Androidapi.Helpers,
  Androidapi.JNI.Media;
type
  TForm3 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    ListBox1: TListBox;
    Button2: TButton;
    ColorKeyAnimation1: TColorKeyAnimation;
    Hz: TLabel;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
    I:Integer;
    frequency1:Integer;
    at1:JAudioTrack;
    soundData: array of Byte;//Shortint;

  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.fmx}

procedure TForm3.Button1Click(Sender: TObject);
begin
       ListBox1.Items.Add(Edit1.Text+'('+IntToStr(I)+')!');
       I:=I+1;
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
   Application.Terminate;
end;

procedure TForm3.Button3Click(Sender: TObject);
var

  LVibrator: JVibrator;

begin

    LVibrator := TJVibrator.Wrap

      ((SharedActivity.getSystemService(TJActivity.JavaClass.VIBRATOR_SERVICE)

      as ILocalObject).GetObjectID); // 调用振动

    if not LVibrator.hasVibrator then

    begin

      ShowMessage('手机不支持震动');

      Exit;

    end;

    LVibrator.vibrate(500); // 振动500毫秒

end;

procedure TForm3.Button4Click(Sender: TObject);
var
     outF,buff_write:Integer;
     chalconfig:Integer;
     audioEncoding:Integer;
     playBufferSize:Integer;
     i,b:Integer;
     a,s2,s3:Double;
     //pk:Pointer;
begin
    outF:=44100;
    chalconfig:= TJAudioFormat.JavaClass.CHANNEL_OUT_MONO;
    audioEncoding:=TJAudioFormat.JavaClass.ENCODING_PCM_8BIT;
    playBufferSize:= TJAudioTrack.JavaClass.getMinBufferSize(outF, chalconfig, audioEncoding);
    playBufferSize:=playBufferSize*2;
    at1:= TJAudioTrack.JavaClass.init(TJAudioManager.JavaClass.STREAM_MUSIC,outF,
                 chalconfig,audioEncoding,playBufferSize,
                 TJAudioTrack.JavaClass.MODE_STREAM);
    i:=0;
    a:=frequency1/(outF*2*3.1415926);
     SetLength (soundData, playBufferSize);
  
    for i := 0 to playBufferSize do
      begin
             s3:=128*sin(a*i);
             b:=round(s3);
             soundData[i]:=Byte(b);
             //i:=i+1;
      end;
     at1.play;
     at1.write(soundData,0,playBufferSize);//这里通不过

end;

procedure TForm3.FormShow(Sender: TObject);
begin
     I:=0;
     frequency1:=1000;
end;

end.
搜索更多相关主题的帖子: android 
2015-07-01 18:18
快速回复:delphi xe7 android 程序出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031236 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved