[fpc-pascal] PPCJVM Android target and bass library function call issue
Mgr. Janusz Chmiel
janusz.chmiel at volny.cz
Sat Aug 10 22:26:40 CEST 2019
I Am very sad, that I do not know, how to correctly call The following
function from bass.so when running apps produced by FPCJVM Android
target mode.
class function BASS_StreamCreateURL(para1: JLString; para2: jint;
para3: jint; para4: CUBBASS.InnerDOWNLOADPROC; para5: JLObject): jint;
static; overload;
Because build in Android Mediaplayer API are very slow when opening 128
KB/S MP3 live streams even on fast WIFI sites.
So it is really necessary to use bass.so, since it load data very fast
and allocates much more less RAM.
But problem is, that there is no easy solution to call bass.so library
and native libraryes in general. Believe Me, simply using external
keyword or other command to load library is not enough.
It is necessary to pack .so library inside .jar archive. And this
archive must also contain compiled Java classes.
My issue is, that I do not know, how to call this function correctly.
Sure, I must initialise bass library first by The following line.
bass.BASS_Init(-1, 44100, 0);
bass.BASS_StreamCreateURL('http://icecast8.play.cz/cro1-128.mp3',
0,0,sta,h);
But powerful Dex creator do not like my approach with JLobject. I have
simply declared h as JLobject by using var command.
And this is very probably non sense for DEX creator. COmpiler do not
assigned my wrong behaviour as bug, but DEX converter yes.
And this is significant warning, that I AM doing something wrong.
Here is The complete source code.
I Am working with Pandroid from MR Cvijanovic. He is really
professional and without his support, I could never know PPCJVM and
Android API functions so much.
unit Test1;
{$mode objfpc}{$H+}
{$modeswitch unicodestrings}
{$namespace zeljus.com.test1}
interface
uses androidr15, Rjava, AActivity, StdCtrls, ZCBass;
type
MainActivity = class(Activity)
public
procedure onCreate(savedInstanceState: AOBundle); override;
public
bass: CUBBASS;
sta: CUBBASS.InnerDOWNLOADPROC;
end;
implementation
procedure MainActivity.onCreate(savedInstanceState: AOBundle);
var
layout : AWLinearLayout;
h : JLObject;
begin
inherited onCreate(savedInstanceState);
layout:= AWLinearLayout.Create(Self);
layout.setOrientation(AWLinearLayout.VERTICAL);
bass:= CUBBASS.create();
bass.BASS_Init(-1, 44100, 0);
bass.BASS_StreamCreateURL('http://icecast8.play.cz/cro1-128.mp3',
0,0,sta,h);
setContentView(layout);
end;
end.
More information about the fpc-pascal
mailing list