Author Topic: BASS(Android) and Delphi XE5  (Read 41560 times)

Ionut Cristea

  • Posts: 1556
BASS(Android) and Delphi XE5
« on: 18 Sep '13 - 07:12 »
   Does anybody know how to achieve a working demo with BASS and Delphi XE5?

Thanks,
Ionut

sak2005

  • Posts: 1011
Re: BASS(Android) and Delphi XE5
« Reply #1 on: 18 Sep '13 - 14:05 »
 Used.. bass.pas added into the dedug folder. Click here

Try write command now. ;D

Example:
Code: [Select]
unit BassPlayer;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, bass; //<--include bass.pas
type
  TForm6 = class(TForm)
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.FormCreate(Sender: TObject);
  var
  strm : Cardinal;
  begin
    Opendialog1.Filter := 'Song File(*.mp3)|*.mp3';
    if Opendialog1.Execute = True then
      begin
        bass.BASS_Init(-1, 44100, bass.BASS_DEVICE_DEFAULT, self.Handle, nil);
        bass.BASS_StreamFree(strm);
        strm := bass.BASS_StreamCreateFile(False,  PChar(Opendialog1.FileName), 0, 0, bass.BASS_UNICODE or bass.BASS_POS_BYTE);
        if strm <> 0 then
          begin
            bass.BASS_ChannelPlay(strm, True);
          end;
    end;
  end;
end.
« Last Edit: 18 Sep '13 - 14:11 by sak2005 »

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #2 on: 18 Sep '13 - 14:27 »
  I need a sample application for using it on Delphi XE5 Android output.

Ionut

Chris

  • Posts: 1864
Re: BASS(Android) and Delphi XE5
« Reply #3 on: 18 Sep '13 - 16:29 »
Used.. bass.pas added into the dedug folder. Click here

Try write command now. ;D

Example:
Code: [Select]
unit BassPlayer;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, bass; //<--include bass.pas
type
  TForm6 = class(TForm)
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.FormCreate(Sender: TObject);
  var
  strm : Cardinal;
  begin
    Opendialog1.Filter := 'Song File(*.mp3)|*.mp3';
    if Opendialog1.Execute = True then
      begin
        bass.BASS_Init(-1, 44100, bass.BASS_DEVICE_DEFAULT, self.Handle, nil);
        bass.BASS_StreamFree(strm);
        strm := bass.BASS_StreamCreateFile(False,  PChar(Opendialog1.FileName), 0, 0, bass.BASS_UNICODE or bass.BASS_POS_BYTE);
        if strm <> 0 then
          begin
            bass.BASS_ChannelPlay(strm, True);
          end;
    end;
  end;
end.

Sorry but this code makes headage

1.) Build a New Mobile Firemonkey App
2.) Setup Your Firemonkey App for the right Screen Width
3.) bass.pas in the SAME Folder as the MainForm.
Build your App.
But One of the biggest Problems is you have to modified the Bass Header.

Mobile Firemonkey does`t Know Ansi!!!!(AnsiChar,AnsiString,PAnsiChar )
This is not tested but I think that should work;
Change all the AnsiStuff in bass to array of byte

add the following function

Code: [Select]
function ShortStringToString(Value: array of Byte): String;
var
  B: TBytes;
  L: Byte;
begin
  Result := '';
  L := Value[0];
  SetLength(B, L);
  Move(Value[1], B[0], L);
  Result := TEncoding.Ansi.GetString(B);
end;
 
procedure StringToShortString(const S: String; var RetVal);
var
  L: Integer;
  I: Byte;
  C: Char;
  P: PByte;
  B: TBytes;
begin
  L := Length(S);
  if L > 255 then
    raise EShortStringConvertError.Create('Strings longer than 255 characters cannot be converted');
  SetLength(B, L);
  P := @RetVal;
  P^ := L;
  Inc(P);
  B := TEncoding.Ansi.GetBytes(S);
  Move(B[0], P^, L);
end;

If i have a little bit more time i will build a tested and working bassheader for android



« Last Edit: 18 Sep '13 - 16:34 by Chris »

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #4 on: 19 Sep '13 - 07:42 »
  I have modified the BASS header, the problem is that i don't know how to ship libbass.so with the apk package.

Ionut

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #5 on: 23 Sep '13 - 17:09 »
No one? ???

Ian @ un4seen

  • Administrator
  • Posts: 22167
Re: BASS(Android) and Delphi XE5
« Reply #6 on: 23 Sep '13 - 17:41 »
I'm not familiar with Delphi XE5, so I'm afraid I can't advise on the specifics of that, but the BASS libraries should be in a "lib" folder inside the APK package (which is a ZIP archive), eg. "lib/armeabi/libbass.so". Eclipse will automatically take the project's "libs" folder and place its contents in the compiled APK's "lib" folder. Perhaps Delphi XE5 does similarly? Do you have the BASS libraries in a "libs" sub-folder of your project's folder?

Chris

  • Posts: 1864
Re: BASS(Android) and Delphi XE5
« Reply #7 on: 23 Sep '13 - 20:06 »
I think the lib must in one of the Android Folders
C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\android-ndk-r8e\platforms\android-14\arch-arm\usr\lib

By the way i think Ian`s Idea should work also

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #8 on: 24 Sep '13 - 10:05 »
 Indeed copying libbass.so to the C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\android-ndk-r8e\platforms\android-14\arch-arm\usr\lib folder compile succeeded, but i'm afraid the application stop working(can't be able to start it). I think that libbass.so is not shipped with the apk, so does anyone know  a method to do that?

Ionut

Chris

  • Posts: 1864
Re: BASS(Android) and Delphi XE5
« Reply #9 on: 24 Sep '13 - 10:21 »
try to copy also the lib in the subdirectory of your ProjectFolder

 C:\Users\YourUsername\Documents\RAD Studio\Projekte\Android\Debug\Project1\library\lib\armeabi
Chris

victor

  • Posts: 134
Re: BASS(Android) and Delphi XE5
« Reply #10 on: 24 Sep '13 - 10:33 »
you need to goto Project / Deployment and append for every configuration (debug, release) that the .so should be delivered into library\lib\armeabi

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #11 on: 24 Sep '13 - 15:15 »
Quote
Insert Quote
you need to goto Project / Deployment and append for every configuration (debug, release) that the .so should be delivered into library\lib\armeabi

This had worked.

Also after so many modification to the bass.pas i finally make it worked. What i tried until now is playing a file from device, and work just fine.

Thanks again guys for the help.

Ionut

victor

  • Posts: 134
Re: BASS(Android) and Delphi XE5
« Reply #12 on: 24 Sep '13 - 19:02 »
how about sharing the bass.pas?

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #13 on: 24 Sep '13 - 19:20 »
 Is not done yet, it has only few functions working properly. I need to test each function to see if its ok. I will post here after i finish it.

Ionut

Bert

  • Posts: 176
Re: BASS(Android) and Delphi XE5
« Reply #14 on: 1 Oct '13 - 13:05 »
Is not done yet, it has only few functions working properly. I need to test each function to see if its ok. I will post here after i finish it.

Ionut

Any progress here?

Stiaan Pretorius

  • Guest
Re: BASS(Android) and Delphi XE5
« Reply #15 on: 15 Oct '13 - 07:42 »
Hi

Please share the project source if possible.

Mush appreciated!

Regards

3delite

  • Posts: 932
Re: BASS(Android) and Delphi XE5
« Reply #16 on: 18 Oct '13 - 00:05 »
+1

firemen

  • Posts: 151
Re: BASS(Android) and Delphi XE5
« Reply #17 on: 18 Oct '13 - 13:42 »
+1

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #18 on: 18 Oct '13 - 16:02 »
 Please try with this . Not fully working but it should do a headstart.

3delite

  • Posts: 932
Re: BASS(Android) and Delphi XE5
« Reply #19 on: 19 Oct '13 - 02:13 »
Thank you very much!

Managed to play a song on my Android device with the help of your code.

Ionut Cristea

  • Posts: 1556
Re: BASS(Android) and Delphi XE5
« Reply #20 on: 19 Oct '13 - 21:38 »
 Glad that you sorted out. I've tried playeing a URL , but not seem to do it. Is BASS for android not working for example with UNICODE strings on BASS_STreamCreateURL?

stiaan

  • Posts: 1
Re: BASS(Android) and Delphi XE5
« Reply #21 on: 21 Oct '13 - 10:16 »
Much appreciated! ;D

Ian @ un4seen

  • Administrator
  • Posts: 22167
Re: BASS(Android) and Delphi XE5
« Reply #22 on: 21 Oct '13 - 16:08 »
I've tried playeing a URL , but not seem to do it. Is BASS for android not working for example with UNICODE strings on BASS_STreamCreateURL?

The BASS_UNICODE flag should be supported by BASS_StreamCreateURL on Android. Are you having problems with a particular URL or all, and what is the error code? To help narrow down the problem (eg. is it Delphi XE5 specific), please see whether you can play the URL(s) on the same device with the NETRADIO example that's included in the Android BASS package.

3delite

  • Posts: 932
Re: BASS(Android) and Delphi XE5
« Reply #23 on: 24 Oct '13 - 01:46 »
I successfully connected to a BASS cast server (my app.) from an Android Delphi XE5 app. through LAN (with unicode URL string). :)

Turlin

  • Posts: 4
Re: BASS(Android) and Delphi XE5
« Reply #24 on: 17 Nov '13 - 00:40 »
Hello.

Please, can you share the project source if possible (example).

Thanks!!