Jump to content
pcplayer99

MediaPlayer Android play MP4 video issue

Recommended Posts

Just a test program, too simple:

  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    SpeedButton1: TSpeedButton;
    MediaPlayer1: TMediaPlayer;
    MediaPlayerControl1: TMediaPlayerControl;
    Layout1: TLayout;
    ProgressBar1: TProgressBar;
    Timer1: TTimer;
    Layout2: TLayout;
    Label1: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    function GetMyFileName: string;

    procedure GetPermissions;
  public
    { Public declarations }
  end;

 

There are some code copy from "RADStudio10.3Demos-master\Object Pascal\Mobile Snippets\VideoPlayback" :

 

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if ProgressBar1.Max <> MediaPlayer1.Duration then
    ProgressBar1.Max := MediaPlayer1.Duration;
  if ProgressBar1.Value <> MediaPlayer1.CurrentTime then
    ProgressBar1.Value := MediaPlayer1.CurrentTime;
end;

 

Compile IDE: Delphi 10.3.1 Community version.

 

Test environment:

A. Android 5.0;

B. Android 9.0;

 

Issues:

 

1. If there is no MediaPlayerControl1, under Android 5.0 it can play MP4 video file, can hear  audio playing of this MP4 file, and ProgressBar1 working fine . But if there is a MediaPlayerControl1, after I call MediaPlayer1.Play, APP will raise a exception: Project testMediaPlayer.apk raised exception class EJNIException with message 'java.io.IOException: Prepare failed.: status=0x80000000'.

 

2. Under Android 9.0, it can play MP4 video, but ProgressBar1 can not work. Set up a break-point on "if ProgressBar1.Max <> MediaPlayer1.Duration then"  every time the timer1 trigger,  MediaPlayer1.Duration is -1.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×