Delphi Firemonkey app on Android doesn't play sound after several play

249 views Asked by At

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;
0

There are 0 answers