unit Unit3;

interface

uses
  System.SysUtils, FMX.Forms, FMX.StdCtrls,System.IOUtils,FMX.WebBrowser,
  System.Classes, FMX.Types, FMX.Controls, FMX.Controls.Presentation;

type
  TForm3 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    WebBrowser1: TWebBrowser;
    Button2: TButton;

    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure WebBrowser1DidFinishLoad(ASender: TObject);

  private
    { Private declarations }


  public
    { Public declarations }

  end;

var
  Form3: TForm3;
  FFileName: string;
  FWantExit: Boolean;

implementation


{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}





procedure TForm3.Button1Click(Sender: TObject); // 关闭浏览器

begin
  WebBrowser1.url := '';
  WebBrowser1.visible := false;
  Close;
end;

procedure TForm3.Button2Click(Sender: TObject); // 浏览器返回

begin
  WebBrowser1.url := 'file://' + FFileName;
end;

procedure TForm3.FormShow(Sender: TObject); // form3显示
begin
  FFileName := System.IOUtils.Tpath.GetSharedDocumentsPath + '/' +
    'music.html';
  Label1.text := 'music.html';
  WebBrowser1.visible := True;
  WebBrowser1.url := 'file://' + FFileName; // 内嵌浏览器中运行当前HTML文件
  Button1.text := '关闭';

end;

procedure TForm3.WebBrowser1DidFinishLoad(ASender: TObject);
var
  s: string;
begin
  s := WebBrowser1.url; //取浏览器地址
  s := copy(s, pos('Documents/', s) + 10, 50); // 取文件名（不带路径）
  Label1.text := s;
end;

end.
