The recent need to play audio directly from the memory stream, thinking of using a third-party audio library bass. It is easy to use the corresponding dynamic library on Windows (in the case of blogs), but there is no corresponding usage description on iOS, which is exactly not an example for Firemonkey. In its official forum to find a demo for OSX, through analysis and testing, the Firemonkey on iOS development using third-party static library processes and methods.
The following is an example of a static library LIBBASS.A using bass on the Delphi XE10.
1, obtain the static library LIBBASS.A file to use, put the LIBBASS.A file in the project can search to the directory, generally placed in the current project directory.
2, to obtain the corresponding header file Bass.h, translated to Pascal interface file Bass.pas, the specific process and methods please Baidu. This is because the official website has OSX's demo, which has OSX's call declaration file Bass.pas, just slightly modify the beginning to add support iOS. Because the Delphi mobile platform does not support Ansichar, in order not to modify the other places, the introduction of the online bytestrings unit DCU, which defines the Ansichar to support the mobile platform.
[Delphi]View Plaincopyprint?
- Unit BASS;
- Interface
- {$IFDEF MSWindows}
- Uses
- Windows;
- {$ELSE}
- {$IFDEF MACOS}
- Uses
- Macapi. Dispatch
- {$IFDEF NEXTGEN}
- , System. Bytestrings
- {$ENDIF}
- ;
- {$ENDIF}
- {$ENDIF}
- Functions
- Const
- {$IFDEF MSWindows}
- Bassdll = ' Bass.dll ';
- {$ENDIF}
- {$IFDEF LINUX}
- Bassdll = ' libbass.so ';
- {$ENDIF}
- {$IFDEF MACOS}
- {$IFDEF iOS} //Add iOS support
- Bassdll = ' LIBBASS.A ';
- {$ELSE} //Add iOS support
- Bassdll = ' Libbass.dylib ';
- {$ENDIF}
- {$ENDIF}
3. If you compile the project in this way, the compiler will report an error that the identifier did not find, as shown in. This is because the static library LIBBASS.A relies on iOS audiotoolbox.framework.
4. Add Audiotoolbox.framework in SDK Manager.
5, Project->options->delphi Compiler->linker->options passed to the LD Linker added "-framework audiotoolbox".
6. You can now compile and publish the program with LIBBASS.A. But if the Bass_streamcreatefile function is used in the program code, the compiler will report an error that the identifier did not find, as shown in. This is because the function uses the iOS cfnetwork.framework.
7, similarly, need to increase the cfnetwork reference. Since Cfnetwork is already synchronized by default in the SDK, it is only possible to add a "-framework cfnetwork" in the 5th step of link option.
8. At this point, you can compile and publish a program that uses bass to play memory MP3.
PS: The official website says bass relies on the framework: Audiotoolbox, SystemConfiguration, Cfnetwork, Accelerate, Coremidi (if Bassmidi is used). So please add the Systemconfiguration,accelerate reference yourself.
Demo Source Download
libbass.a:http://s.cdz.la/file/7690588
bass.pas:http://s.cdz.la/file/7690589
demo:http://s.cdz.la/file/7690592
http://blog.csdn.net/tht2009/article/details/50183721
Firemonkey third-party static libraries using iOS (Link Binary with Libraries)