Android上的Delphi Firemonkey应用程序在几次播放后都没有播放声音

发布于 2025-02-04 18:32:21 字数 1044 浏览 4 评论 0原文

我有问题在Android上播放声音文件。请参阅下面的我的代码,因为它可以正常运行近200次,但是听起来并没有出现。

我接收java.lang.runtimeException:setDatasource失败:stastus = 0x800000000。

有时它也会给我带来错误的java.oi.ioexception:准备失败。:状态= 0x1。

请让我知道下面的代码是否有任何问题,或者是否有人遇到此问题,请提供帮助。

谢谢

             MediaPlayer1.FileName := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetPublicPath,'sound/Warning.3gp');
             if MediaPlayer1.Media <> nil then
             begin
                 MediaPlayer1.Play;
             end;

注意:我已经从项目中删除了MediaPlayer1,并试图创建运行时间并在此之后销毁,但最终得到了完全相同的结果。

  if(lMode=2) and (myQuery.RecordCount=0) then
  begin
      var mp : TMediaPlayer;
      mp:=TMediaPlayer.Create(Self); // or AParent if it is a passed variable
      mp.Parent:=Self; // (AParent) you must set its parent

      mp.FileName := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetPublicPath,'sound/NOTFOUND.3gp');
      if mp.Media <> nil then
      begin
         mp.Play;
      end;
      mp.Free;
   end;

I having problem to play sound files on android. Please see below my code as it works fine up to nearly 200 times but after that sounds doesn't come up.

I receive java.lang.RuntimeException: setDataSource failed: stastus = 0x800000000.

And sometimes it also gives me error java.oi.IOException: Prepare failed.: status=0x1.

Please let me know if the code below has any problem or if anyone experienced this issue please help.

Thanks

             MediaPlayer1.FileName := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetPublicPath,'sound/Warning.3gp');
             if MediaPlayer1.Media <> nil then
             begin
                 MediaPlayer1.Play;
             end;

Note: I have removed the MediaPlayer1 from the project and tried to create run time and destroy after but ended up with exactly the same result.

  if(lMode=2) and (myQuery.RecordCount=0) then
  begin
      var mp : TMediaPlayer;
      mp:=TMediaPlayer.Create(Self); // or AParent if it is a passed variable
      mp.Parent:=Self; // (AParent) you must set its parent

      mp.FileName := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetPublicPath,'sound/NOTFOUND.3gp');
      if mp.Media <> nil then
      begin
         mp.Play;
      end;
      mp.Free;
   end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文